问题
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