我可以在 WebSphere 中设置非事务性 JMS 连接工厂吗?

发布于 2024-12-09 08:22:16 字数 306 浏览 0 评论 0原文

该工厂将基于默认消息传递提供程序

这样做的原因是我有一个模拟 MDB 来代替外部系统,通常通过 Websphere MQ 连接。模拟和测试的应用程序安装在同一台服务器上,因此我需要确保在循环中

request -> mock listener -> mock reply -> response

requestreply 是两个单独的事务。

我在控制台中看不到任何将工厂从事务管理器的监督中删除的选项。

The factory will be based on Default messaging provider.

The reason for doing so is I have a mock MDB in place of an external system, normally connected via Websphere MQ. The mock and the tested application are installed on the same server, so I need to make sure that in the cycle

request -> mock listener -> mock reply -> response

request and reply are two separate transactions.

I can't see any option in the console to remove the factory from transaction manager's supervision.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

九命猫 2024-12-16 08:22:16

您的观察是正确的,JMS 连接工厂无法配置为不加入当前事务。我有点不确定你想在这里实现什么,但我将做出以下假设:

  1. 客户端发送消息
  2. 侦听器拾取消息并发送回复
  3. 客户端拾取回复

在这种情况下,客户端需要发送并提交监听器之前的消息将让它发送回复。侦听器可以在一个事务中接收和回复,但客户端需要两个事务。我还假设客户端是 EJB。

对此的一种解决方案是使用 bean 管理的事务。在这种情况下,您可以手动开始事务并在 1 点左右提交,并在 3 点左右再次提交。这将导致消息被发送。

另一种解决方案是在一个 EJB 方法中使用 RequiresNew 进行发送,并在另一个 EJB 方法中使用 RequiresNew 进行接收。然后,客户端调用发送 EJB 方法,然后调用接收 EJB 方法,每个方法都有自己的事务。

You are correct in your observation that the JMS Connection Factory cannot be configured to not enlist in the current transaction. I am a little unsure of what you are trying to achive here, but I'm going to make the following assumption:

  1. Client sends message
  2. Listener picks up message and sends reply
  3. Client picks up the reply

In this scenario the client needs to send and commit the message before the listener will get it to send the reply. The listener can receive and reply in one transaction, but the client needs two. I am furthermore assuming that the client is an EJB.

One solution to this would be use bean managed transactions. In this case you can manually begin a transaction and commit it around 1 and again around 3. This will cause the message to be sent.

Another solution would be to do the send in an EJB method with RequiresNew and the receive in another EJB method with RequiresNew. Then the client calls the send EJB method followed by the receive EJB method and each method has its own transaction.

給妳壹絲溫柔 2024-12-16 08:22:16

不能从 ejb-jar.xml 中执行此操作吗?

<enterprise-beans>
    <message-driven id="MDB">
        <ejb-name>MDB</ejb-name>
        <ejb-class>com.myapp.listener.MDB</ejb-class>
        <messaging-type>javax.jms.MessageListener</messaging-type>
        <transaction-type>Container</transaction-type>
        <message-destination-type>javax.jms.Queue</message-destination-type>
    </message-driven>
</enterprise-beans>

<assembly-descriptor>
    <container-transaction>
        <method>
            <ejb-name>MDB</ejb-name>
            <method-name>onMessage</method-name>
            <method-params>
                <method-param>javax.jms.Message</method-param>
            </method-params>
        </method>
        <trans-attribute>Never</trans-attribute>
    </container-transaction>
</assembly-descriptor>

Can you not do this from the ejb-jar.xml?

<enterprise-beans>
    <message-driven id="MDB">
        <ejb-name>MDB</ejb-name>
        <ejb-class>com.myapp.listener.MDB</ejb-class>
        <messaging-type>javax.jms.MessageListener</messaging-type>
        <transaction-type>Container</transaction-type>
        <message-destination-type>javax.jms.Queue</message-destination-type>
    </message-driven>
</enterprise-beans>

<assembly-descriptor>
    <container-transaction>
        <method>
            <ejb-name>MDB</ejb-name>
            <method-name>onMessage</method-name>
            <method-params>
                <method-param>javax.jms.Message</method-param>
            </method-params>
        </method>
        <trans-attribute>Never</trans-attribute>
    </container-transaction>
</assembly-descriptor>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文