简体   繁体   中英

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.

<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.

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). 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.

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. 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?

Finally if WSO2 service is shutdown during processing, the message is not requeued. Is there an alternative to the configuration proposed here: 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! Further information can be found in guaranteed-delivery article[1], EIP article for DCL[2], Message forwarding procssor[3]

[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

[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. 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"/>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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