How to setup transaction in Camel JMS Route

青春壹個敷衍的年華 提交于 2020-07-10 07:02:23

问题


How do I setup transaction in JMS route to rollback or not consume a message when an exception occurs. Below is my route. MQ is ActiveMQ.

from("jms:queue:myQueue")
        .routeId("myRoute")
        .doTry()
            .toF("reactive-streams:myStream")
        .doCatch(Exception.class)
            .process(exchange -> exchange.getFromEndpoint().stop())
        .end();`

回答1:


Simply adding transacted did the job! Also, had to enable connection pooling and camel-jms-starter (for default factories).

from("jms:queue:myQueue?transacted=true")
        .routeId("myRoute")
        .doTry()
            .toF("reactive-streams:myStream")
        .doCatch(Exception.class)
            .process(exchange -> exchange.getFromEndpoint().stop())
        .end();


来源:https://stackoverflow.com/questions/62743621/how-to-setup-transaction-in-camel-jms-route

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!