简体   繁体   English

在Apache骆驼中使用JMS路由时,事务性客户端和transacted = true有什么区别?

[英]What is the difference between a transactional client and transacted=true when using a JMS route in apache camel?

I have a camel route where the from and to endpoints are jms. 我有一条骆驼路线,起点和终点均为jms。 I also have error handling ON. 我也有错误处理。

Now, I wanna protect this message handling with a jms transaction handler. 现在,我想使用jms事务处理程序来保护此消息处理。 For that I have two options: 为此,我有两个选择:

  1. Either configure the route to use as shown here 无论是配置为使用路线如图所示这里
  2. Or just configure the JMS endpoints to use transacted=true as shown here 或者只是配置JMS端点使用transacted=true如图所示这里

What is the difference between two? 两者有什么区别? Can anybody tell me which one is better and which to use? 谁能告诉我哪个更好,使用哪个?

According to this (see Claus Ibsen's answer) <transacted> ensures the Camel processing runs inside a TX context. 根据这个 (见克劳斯易卜生的回答) <transacted>确保骆驼处理的TX上下文内运行。 Where as without that the TX context is only for the broker (and only within the same unit of work from the same JMS session). 在没有上下文的情况下,TX上下文仅用于代理(并且仅在同一JMS会话的同一工作单元内)。 Whereas transacted=true enables transactional consuming of messages. transacted=true使事务能够消耗消息。 There's also an example there of where you would actually want to use <transacted> (consuming from http endpoint): 这里还有一个示例,您实际在何处要使用<transacted> (从http端点使用):

from jetty:http
transacted
to jms
to file

So if you're just passing messages from one JMS endpoint to another on sthe same broker, seems like you don't actually need a transacted route. 因此,如果您只是将消息从一个JMS端点传递到同一代理上的另一个端点,似乎您实际上并不需要事务处理路由。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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