如何在 Camel JMS Route 中设置事务 [英] How to setup transaction in Camel JMS Route
本文介绍了如何在 Camel JMS Route 中设置事务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在 JMS 路由中设置事务以在发生异常时回滚或不使用消息.下面是我的路线.MQ 是 ActiveMQ.
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();`
推荐答案
只需添加事务即可!此外,必须启用连接池和camel-jms-starter(用于默认工厂).
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();
这篇关于如何在 Camel JMS Route 中设置事务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文