camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: Camel + ActiveMQ + Spring Problems
Date Tue, 02 Mar 2010 15:50:28 GMT
On Tue, Mar 2, 2010 at 4:48 PM, bzaks1424 <bzaks1424@gmail.com> wrote:
>
> Unfortunately I get a similar cast exception when I just go straight to
> BlobMessage. Is there a javax.jms.BlobMessage?

Why dont you go check the Javadoc API from SUN which lists what types there are?

There is no Blob type, but there is a Stream or Bytes type AFAIK

And obviously in your case you get an ActiveMQMessage and NOT a
BlobMessage, which you can see immediately in the stacktrace.


> http://activemq.apache.org/blob-messages.html
> Exception:
> java.lang.ClassCastException: org.apache.activemq.command.ActiveMQMessage
> cannot be cast to org.apache.activemq.BlobMessage
>        at
> com.walgreens.scale.listener.PayloadQueueListener.onMessage(PayloadQueueListener.java:29)
>        at
> org.apache.activemq.camel.converter.ActiveMQMessageConverter$1.process(ActiveMQMessageConverter.java:68)
>        at
> org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:83)
>        at
> org.apache.camel.impl.ProcessorEndpoint.onExchange(ProcessorEndpoint.java:95)
>        at
> org.apache.camel.impl.ProcessorEndpoint$1.process(ProcessorEndpoint.java:65)
>        at
> org.apache.camel.processor.SendProcessor$1.doInProducer(SendProcessor.java:97)
>        at
> org.apache.camel.processor.SendProcessor$1.doInProducer(SendProcessor.java:95)
>        at org.apache.camel.impl.ProducerCache.doInProducer(ProducerCache.java:146)
>        at
> org.apache.camel.processor.SendProcessor.doProcess(SendProcessor.java:94)
>        at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:82)
>        at
> org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:67)
>        at
> org.apache.camel.processor.DelegateProcessor.processNext(DelegateProcessor.java:53)
>        at
> org.apache.camel.processor.DelegateProcessor.proceed(DelegateProcessor.java:82)
>        at
> org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:93)
>        at
> org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:67)
>        at
> org.apache.camel.processor.RedeliveryErrorHandler.processExchange(RedeliveryErrorHandler.java:223)
>        at
> org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:153)
>        at
> org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:91)
>        at
> org.apache.camel.processor.DefaultErrorHandler.process(DefaultErrorHandler.java:49)
>        at
> org.apache.camel.processor.DefaultChannel.process(DefaultChannel.java:206)
>        at
> org.apache.camel.processor.UnitOfWorkProcessor.processNext(UnitOfWorkProcessor.java:54)
>        at
> org.apache.camel.processor.DelegateProcessor.process(DelegateProcessor.java:48)
>        at
> org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:67)
>        at
> org.apache.camel.component.jms.EndpointMessageListener.onMessage(EndpointMessageListener.java:83)
>
>
> Claus Ibsen-2 wrote:
>>
>> Hi
>>
>> You should generally only cast to the known JMS types from the JMS
>> spec, eg. javax.jms.TextMessage, javax.jms.BytesMessage.
>>
>> If you want to cast to specialized AMQ types then use instanceof to
>> check the type to be sure.
>>
>> On Tue, Mar 2, 2010 at 4:16 PM, bzaks1424 <bzaks1424@gmail.com> wrote:
>>>
>>> I am writing an application using spring as my base, camel as my routing
>>> tool
>>> and activemq as my transport.
>>>
>>> I wrote a listener to capture the message as it arrives into the Queue -
>>> and
>>> process it right away.
>>>
>>> Code:
>>> @Service
>>> public class PayloadQueueListener implements MessageListener {
>>>        @Override
>>>        public void onMessage(Message message) {
>>>                try {
>>>                        ActiveMQBlobMessage blobMessage =
>>> (ActiveMQBlobMessage) message;
>>>
>>> However - whenever I try to to do the cast - it throws a class cast
>>> exception:
>>> Exception:
>>> org.apache.camel.RuntimeCamelException: java.lang.RuntimeException:
>>> java.lang.ClassCastException: org.apache.activemq.command.ActiveMQMessage
>>> cannot be cast to org.apache.activemq.command.ActiveMQBlobMessage
>>>        at
>>> org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1039)
>>>        at
>>> org.apache.camel.component.jms.EndpointMessageListener.onMessage(EndpointMessageListener.java:103)
>>>        at
>>> org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:543)
>>>        at
>>> org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:482)
>>>        at
>>> org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:451)
>>>        at
>>> org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:323)
>>>        at
>>> org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:261)
>>>        at
>>> org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:982)
>>>        at
>>> org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(DefaultMessageListenerContainer.java:974)
>>>        at
>>> org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:876)
>>>        at java.lang.Thread.run(Thread.java:619)
>>>
>>> Do I need to do something specifically with ActiveMQ or is this an issue
>>> with the way Camel is routing message and type casting it to the queue?
>>> --
>>> View this message in context:
>>> http://old.nabble.com/Camel-%2B-ActiveMQ-%2B-Spring-Problems-tp27757055p27757055.html
>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>
>>>
>>
>>
>>
>> --
>> Claus Ibsen
>> Apache Camel Committer
>>
>> Author of Camel in Action: http://www.manning.com/ibsen/
>> Open Source Integration: http://fusesource.com
>> Blog: http://davsclaus.blogspot.com/
>> Twitter: http://twitter.com/davsclaus
>>
>>
>
> --
> View this message in context: http://old.nabble.com/Camel-%2B-ActiveMQ-%2B-Spring-Problems-tp27757055p27757436.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Mime
View raw message