简体   繁体   English

WSO2中的JMS消费者事务

[英]JMS consumer transactions in WSO2

I am trying to configure WSO2 to consume message from ActiveMQ, and requeue when an error is raised during processing - typically when the call to the remote web service fails. 我正在尝试将WSO2配置为使用来自ActiveMQ的消息,并在处理期间引发错误时重新排队 - 通常是在对远程Web服务的调用失败时。

<proxy name="SimpleStockQuoteService" transports="jms" startOnLoad="true">
  <target>
     <inSequence onError="JSMErrorHandling">
        <log level="full"/>
        <send>
           <endpoint>
              <address uri="http://localhost/testapp"/>
           </endpoint>
        </send>
        <log level="full"/>
        <log level="custom">
           <property name="Custom log" value="End In Sequence"/>
        </log>
     </inSequence>
     <outSequence>
        ...
     </outSequence>
  </target>
</proxy>
<sequence name="JSMErrorHandling">
  <log level="custom">
     <property name="Error" value="Error executing sequence"/>
  </log>
  <property name="SET_ROLLBACK_ONLY" value="true" scope="axis2"/>
  <drop/>
</sequence>

Activemq is configured in axis2.xml with the property transport.jms.SessionTransacted set to true. 在axis2.xml中配置Activemq,并将属性transport.jms.SessionTransacted设置为true。

The JMS roll-back/redelivery/[redirection to dead letter] features work as expected when the format of remote URL is invalid (for instance using wrong protocol). 当远程URL的格式无效时(例如使用错误的协议),JMS回滚/重新传递/ [重定向到死信]功能可以正常工作。 However if I stop the remote web server, or using invlaid server name, the message is not requeued, although the error is handled by JMSErrorHandling sequence. 但是,如果我停止远程Web服务器或使用invlaid服务器名称,则消息不会被重新排队,尽管错误由JMSErrorHandling序列处理。

Here is a excerpt from the log 这是日志的摘录

[2013-06-04 12:17:47,810]  INFO - LogMediator To: , WSAction: urn:mediate, SOAPAction: urn:mediate, MessageID: ID:GCHESNEL764-57101-1370344525419-9:1:1:1:1, Direction: request, Envelope: <?xml ver
[2013-06-04 12:17:47,813]  INFO - LogMediator To: , WSAction: urn:mediate, SOAPAction: urn:mediate, MessageID: ID:GCHESNEL764-57101-1370344525419-9:1:1:1:1, Direction: request, Envelope: <?xml ver
[2013-06-04 12:17:47,814]  INFO - LogMediator Custom log = End In Sequence
[2013-06-04 12:17:48,818]  WARN - ConnectCallback Connection refused or failed for : localhost/127.0.0.1:80
[2013-06-04 12:17:48,821]  WARN - EndpointContext Endpoint : endpoint_413907dd1d4e2370ea0ae277fbfebcaf6504f196a11459bb will be marked SUSPENDED as it failed
[2013-06-04 12:17:48,823]  WARN - EndpointContext Suspending endpoint : endpoint_413907dd1d4e2370ea0ae277fbfebcaf6504f196a11459bb - current suspend duration is : 30000ms - Next retry after : Tue J
[2013-06-04 12:17:48,824]  INFO - LogMediator Error = Error executing sequence

It looks like WSO2 is making the HTTP call asynchronously and the JMS transaction is committed before the request is fails. 看起来WSO2异步进行HTTP调用,并且在请求失败之前提交JMS事务。 Can this behavior be configured? 可以配置此行为吗?

If further processing is required - ie chaining remote service calls - how do I insure that the JMS transaction is left open in out sequence, so it can be rolled back if an error occurs at later stage? 如果需要进一步处理 - 即链接远程服务调用 - 我如何确保JMS事务按顺序保持打开状态,以便在后期发生错误时可以回滚?

Finally if WSO2 service is shutdown during processing, the message is not requeued. 最后,如果在处理期间关闭WSO2服务,则不会将消息重新排队。 Is there an alternative to the configuration proposed here: http://docs.wso2.org/wiki/display/ESB460/JMS+FAQ#JMSFAQ-Howtopreventmessagelossduetounavailabilityofadatasource 是否有替代这里提出的配置: http//docs.wso2.org/wiki/display/ESB460/JMS+FAQ#JMSFAQ-Howtopreventmessagelossduetounavailabilityofadatasource

Guillaume 纪尧姆

Use the Messagestore and the MessageProcessor that has been in implemented in wso2 ESB You can achieve the given scenario using Store and process Technic! 使用已在wso2 ESB中实现的Messagestore和MessageProcessor您可以使用Store和process Technic实现给定的方案! Further information can be found in guaranteed-delivery article[1], EIP article for DCL[2], Message forwarding procssor[3] 更多信息可以在保证交付文章[1],DCL的EIP文章[2],消息转发procssor [3]中找到。

[1] http://wso2.com/library/articles/2014/01/guaranteed-delivery-with-Message-Store-Message-Processor%20/ [1] http://wso2.com/library/articles/2014/01/guaranteed-delivery-with-Message-Store-Message-Processor%20/

[2] http://docs.wso2.org/display/IntegrationPatterns/Dead+Letter+Channel [2] http://docs.wso2.org/display/IntegrationPatterns/Dead+Letter+Channel

[3] http://docs.wso2.org/display/ESB481/Sample+702%3A+Introduction+to+Message+Forwarding+Processor [3] http://docs.wso2.org/display/ESB481/Sample+702%3A+Introduction+to+Message+Forwarding+Processor

I just ran into the same issue. 我刚遇到同样的问题。 The problem is the send mediator is non-blocking. 问题是send mediator是非阻塞的。 Add the following property to your insequence to make it a blocking call, thus allowing the session to be rolled back after failure. 将以下属性添加到您的序列中以使其成为阻塞调用,从而允许会话在失败后回滚。

<property name="ClientApiNonBlocking" action="remove" scope="axis2"/>

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

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