Camel: retrieving object in activemq message

2019-08-07 09:15发布

问题:

Is there a way to put object in message in camel route process.

lets say i have a route

from("direct:send")
.process(queueProcessor)
.to(activemqEndPoint)

and in the queueProcessor i am putting an object in the exchange,

Now, I have a listener which listens to activemqEndPoint(queue)

public void onMessage(Message message) {
    try {
        //here i want to get the message i set it in the exchange
     }

Any help?? THanks in advance

回答1:

trying this worked for me

from("direct:send")
.process(queueProcessor)
.to(parallelQueue + "?jmsMessageType=Object")


回答2:

sure, Camel will put an ActiveMQObjectMessage in the queue and you can just cast the message back into your object type...

ActiveMQObjectMessage message = (ActiveMQObjectMessage) message;

MyObject myObj = (MyObject) message.getObject();