Camel: retrieving object in activemq message

2019-08-07 09:53发布

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

2条回答
劳资没心,怎么记你
2楼-- · 2019-08-07 09:56

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();

查看更多
戒情不戒烟
3楼-- · 2019-08-07 09:59

trying this worked for me

from("direct:send")
.process(queueProcessor)
.to(parallelQueue + "?jmsMessageType=Object")
查看更多
登录 后发表回答