当从一个 JMS 队列持久化到另一个 JMS 队列时,是否应该使用 JmsTransactionManager [英] Should JmsTransactionManager be used when persisting from one JMS Queue to another JMS Queue

查看:33
本文介绍了当从一个 JMS 队列持久化到另一个 JMS 队列时,是否应该使用 JmsTransactionManager的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要求:我们需要从 JMS 队列(由不同的应用程序发布)检索消息并将该消息保存在我们的 JMS 队列中.需要整个流都是事务性的,以便在消息无法在下游 JMS 队列中持久化的情况下,不应确认从上游 JMS 队列接收的消息.我的配置如下

Requirement: We need to retrieve a message from a JMS Queue(published by a different application) and persist the message in our JMS Queue. Need the entire flow to be transactional so in case a message cannot be persisted in the downstream JMS queue, message received from upstream JMS Queue should not be acknowledged. My configuration is as below

<int-jms:message-driven-channel-adapter
   id="MessageDrivenAdapter" channel=" jmsMessageChannel " destination="sourceDestination" 
     connectionFactory="CF1"
acknowledge="transacted"
    />

<int:channel id=" jmsMessageChannel " />
<int-jms:outbound-channel-adapter id="sendsomemsg"
    channel=" jmsMessageChannel "  destination="finalDestination"
    connectionFactory="CF2"
    session-transacted="true" />

在这种情况下我是否需要使用 JmsTransactionManager 或者应该在配置之上就足够了.我们可以处理重复的消息,所以我相信我们不需要 XA 事务.

Do I need to use JmsTransactionManager in this scenario or should be above configuration suffice. We can handle duplicate messages so I believe we do not need an XA transaction.

推荐答案

您在这里肯定需要 XA 事务,因为您正在使用多个单独的事务资源.即使它们都是 JMS,也不意味着它们可以共享事务.

You definitely need XA transaction here because you are using several separate transactional resources. Even if they both are JMS, that doesn't mean that they can share transaction.

OTOH,您可以尝试像 ChainedTransactionManager 这样的解决方案,并链接两个 JmsTransactionManager - 每个 JMS 资源一个.

OTOH you can try a solution like ChainedTransactionManager and chain two JmsTransactionManagers - one for each your JMS resource.

更多信息在 Dave Syer 的 文章.

More info is in Dave Syer's article.

这篇关于当从一个 JMS 队列持久化到另一个 JMS 队列时,是否应该使用 JmsTransactionManager的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆