【问题标题】:Service Activator not completing before next message from JMS is processed在处理来自 JMS 的下一条消息之前,Service Activator 未完成
【发布时间】:2015-08-19 03:52:51
【问题描述】:

设置:
我正在使用 Spring Integration 从消息队列中获取消息。消息采用 XML 格式,我的服务激活器调用名为 parseCustPaymentXML 的方法,处理 XML 消息,并将其存储在 Java 对象中。之后,从 parseCustPaymentXML 调用另一个名为 processCustPayment 的方法,该方法获取 Java 对象并将它们插入数据库。下面是我如何设置入站 JMS 和服务激活器...

<int:channel id="jmsInChannel" />

<int-jms:message-driven-channel-adapter
        destination="custPaymentRequestDestination"
        connection-factory="jmsConnectionFactory"
        channel="jmsInChannel"
        concurrent-consumers="1" />

<int:service-activator id="parseCustPaymentServiceActivator"
                       ref="custPaymentService"
                       input-channel="jmsInChannel"
                       method="parseCustPaymentXML"
                       requires-reply="true" />

问题:
该流程运行不会花费很长时间,但是如果在 parseCustPaymentXML 或 processCustPayment 仍在运行时收到消息,则会拉出该消息,并与第一个消息流程同时启动 parseCustPaymentXML。这不是我喜欢的行为。我希望第一条消息在下一条消息开始之前完全完成(非并发)。

如果需要更多信息以获取帮助,请告诉我。

【问题讨论】:

    标签: java spring jms spring-integration spring-jms


    【解决方案1】:

    使用 concurrent-consumers="1" 时,一次只会处理一条消息;确保您没有声明您的入站适配器两次?这是一个常见的错误——尤其是在 Web 应用程序中。

    打开 DEBUG 日志记录,一切都应该变得清晰

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-11-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多