You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by bzaks1424 <bz...@gmail.com> on 2010/03/02 16:16:11 UTC

Camel + ActiveMQ + Spring Problems

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.


Re: Camel + ActiveMQ + Spring Problems

Posted by bzaks1424 <bz...@gmail.com>.
I actually figured out what's going on to some degree - and wondered if
anyone could give me any better advice on using camel:

Okay - in my camel context I have created a route from my payload queue to
my "listener" bean. Which in the case of ActiveMQ is not the same as
actually implementing a listener on the queue. I did some debugging and
found out the message that's getting passed through Camel is a message with
all of the parameters set to defaults (read: an instantiated message that
basically has all null parameters). I believe this is because Camel is
taking the "BlobMessage" delivered to it by ActiveMQ and converting it to a
ActiveMQMessage but since Setters aren't exact - reflection is not working
as it should.

Since I need the actual Message object from the queue - is it possible to
bypass or tell Camel not to transform the object coming off the queue?

Sorry for all the emails - I'm still learning!

-Michael P.



bzaks1424 wrote:
> 
> I looked through the javadoc and there wasn't blob support - which is why
> I've been casting to things ActiveMQ Specific.
> 
> Its just really weird - because I know that I can "create" a blob message.
> Now granted - I'm well aware this is ActiveMQ specific code. Is that going
> to affect the way Camel routes this around?
> Basically - I'm connecting to a different broker at any one point as
> defined by an external source - so I need to create a connection to a new
> broker on the fly and send it this file. Given my inexperience with Camel
> - is there a better way to handle this? Believe me I'm all "ears" (or eyes
> at it would be)
> 
> Code:
> ActiveMQSession session = null;
> MessageProducer producer = null;
> try {
> 	factoryBean = new ActiveMQConnectionFactory(brokerURL
> 			.toString());
> 	connection = factoryBean.createConnection();
> 	connection.start();
> 	session = (ActiveMQSession) connection.createSession(false,
> 			Session.AUTO_ACKNOWLEDGE);
> 	Destination payloadQueue = session
> 			.createQueue("com.example.payload");
> 	producer = session.createProducer(null);
> 	BlobMessage blobMessage = session.createBlobMessage(new
> File("C:/test.tar.gz");
> 	blobMessage.setStringProperty("PAYLOAD_FILENAME", "test.tar.gz");
> 	producer.send(payloadQueue, blobMessage);
> } catch(Exception e) {
> 	e.printStackTrace();
> } finally {
> 	try {
> 		producer.close();
> 		session.close();
> 		connection.stop();
> 		connection.close();
> 	} catch (Exception e) {
> 	// Ignore it.
> 	}
> }
> 
> Claus Ibsen-2 wrote:
>> 
>> On Tue, Mar 2, 2010 at 4:48 PM, bzaks1424 <bz...@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 <bz...@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
>> 
>> 
> 
> 

-- 
View this message in context: http://old.nabble.com/Camel-%2B-ActiveMQ-%2B-Spring-Problems-tp27757055p27769277.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Camel + ActiveMQ + Spring Problems

Posted by bzaks1424 <bz...@gmail.com>.
I looked through the javadoc and there wasn't blob support - which is why
I've been casting to things ActiveMQ Specific.

Its just really weird - because I know that I can "create" a blob message.
Now granted - I'm well aware this is ActiveMQ specific code. Is that going
to affect the way Camel routes this around?
Basically - I'm connecting to a different broker at any one point as defined
by an external source - so I need to create a connection to a new broker on
the fly and send it this file. Given my inexperience with Camel - is there a
better way to handle this? Believe me I'm all "ears" (or eyes at it would
be)

Code:
ActiveMQSession session = null;
MessageProducer producer = null;
try {
	factoryBean = new ActiveMQConnectionFactory(brokerURL
			.toString());
	connection = factoryBean.createConnection();
	connection.start();
	session = (ActiveMQSession) connection.createSession(false,
			Session.AUTO_ACKNOWLEDGE);
	Destination payloadQueue = session
			.createQueue("com.example.payload");
	producer = session.createProducer(null);
	BlobMessage blobMessage = session.createBlobMessage(new
File("C:/test.tar.gz");
	blobMessage.setStringProperty("PAYLOAD_FILENAME", "test.tar.gz");
	producer.send(payloadQueue, blobMessage);
} catch(Exception e) {
	e.printStackTrace();
} finally {
	try {
		producer.close();
		session.close();
		connection.stop();
		connection.close();
	} catch (Exception e) {
	// Ignore it.
	}
}

Claus Ibsen-2 wrote:
> 
> On Tue, Mar 2, 2010 at 4:48 PM, bzaks1424 <bz...@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 <bz...@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
> 
> 

-- 
View this message in context: http://old.nabble.com/Camel-%2B-ActiveMQ-%2B-Spring-Problems-tp27757055p27757608.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Camel + ActiveMQ + Spring Problems

Posted by Claus Ibsen <cl...@gmail.com>.
On Tue, Mar 2, 2010 at 4:48 PM, bzaks1424 <bz...@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 <bz...@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

Re: Camel + ActiveMQ + Spring Problems

Posted by bzaks1424 <bz...@gmail.com>.
Unfortunately I get a similar cast exception when I just go straight to
BlobMessage. Is there a javax.jms.BlobMessage?
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 <bz...@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.


Re: Camel + ActiveMQ + Spring Problems

Posted by Claus Ibsen <cl...@gmail.com>.
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 <bz...@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