简体   繁体   中英

How to implement an event-driven consumer in Apache Camel and get JMS Message

Hi I'm struggling with Apache Camel,

i want the "real" javax.jms.TextMessage in my custom Consumer-Bean. But all I get is the Message-Text as String.

Config:

     <camelContext xmlns="http://camel.apache.org/schema/spring"> 
     <route id="route_dispatching"> 
        <from uri="activemq:queue:queue.dispatcher.replyqueue"/> 
        <to uri="bean:dispatcherbean"/>
       </route>
     </camelContext>
     <bean id="dispatcherbean" class="com.company.Dispatcher"/>

Code of Dispatcher Bean:

     public class Dispatcher{
           private static final Log LOG = LogFactory.getLog(Dispatcher.class);
          public void handleEvent(Object eventPayload) throws Exception
          {  
                LOG.info("got an event"); 
          }
     }

The eventPayload Object is of type String and not javax.jms.TextMessage. I tried to change uri="activemq:queue to uri="jms:queue, but then I get some Errors about missing Connection Factories :-(

Hope someone may help?

Regards, Tobi

您是否尝试过在POJO类中将类型从Object更改为javax.jms.TextMessage?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM