1
I have configured Apache ActiveMQ with transaction and CLIENT_ACKNOWLEDGE in WSO2 ESB 4.7.0. The axis2.xml config is :

<parameter name="transport.jms.SessionTransacted">true</parameter>
<parameter name="transport.jms.SessionAcknowledgement" locked="true">CLIENT_ACKNOWLEDGE</parameter>
I have a simple passthrough proxy with jms transport which passes the messages in the JMS queue to a jax-rs service. The proxy code is :

<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
   name="MediaMoveQueue"
   transports="jms"
   startOnLoad="true"
   trace="enable">
<description/>
<target>
  <inSequence>
     <property name="messageType" value="application/json" scope="axis2"/>
     <property name="ContentType" value="application/json" scope="axis2"/>
     <send receive="JmsRollbackSequence">
        <endpoint>
           <address uri="http://192.168.1.2:9766/RestMediaMove_1.0.0/services/rest_media_move_i_f/restmediamoveif/hello"/>
        </endpoint>
     </send>

     <log level="custom">
        <property name="In MediaMoveQueue JMSERROR"
                  expression="get-property('JMSERROR')"/>
     </log>


     <switch source="get-property('JMSERROR')">
        <case regex="true">
           <property name="SET_ROLLBACK_ONLY" value="true" scope="axis2"/>
           <log level="custom">
              <property name="In MediaMoveQueue Transaction Action"
                        value="Rollbacked"/>
           </log>
        </case>
        <case regex="false">
           <log level="custom">
              <property name="In MediaMoveQueue Transaction Action"
                        value="Committed"/>                  
           </log>
         </case>
         <default>
           <property name="SET_ROLLBACK_ONLY" value="true" scope="axis2"/>
           <log level="custom">
              <property name="In MediaMoveQueue Transaction Action default"
                        value="Rollbacked"/>
           </log>
        </default>
     </switch>
  </inSequence>
  <outSequence>
     <log level="full">
        <property name="test" value="IN outsequence"/>
     </log>
     <send/>
  </outSequence>
</target>
<parameter name="transport.jms.ContentType">
  <rules>
     <jmsProperty>contentType</jmsProperty>
     <default>application/json</default>
  </rules>
</parameter>
</proxy>

The JmsRollbackSequence sequence receives the reply from the jax-rs service and depending on the reply success or failure returned, I would like to rollback the JMS transaction. But if I set the property in the JmsRollbackSequence it has absolutely no effect ( I tried it first before using the sequence shown below). The transaction is never rolled back. The rollback works only if the property is set in the inSequence. Here is the code for the JmsRollbackSequence :

<?xml version="1.0" encoding="UTF-8"?>
<sequence xmlns="http://ws.apache.org/ns/synapse" name="JmsRollbackSequence">
<property name="JMSERROR" value="true"/>
    <log level="full">
      <property name="test" value="IN JmsRollbackSequence"/>
     </log>

</sequence>

So I tried to set up a property called JMSERROR in the JmsRollbackSequence and by reading it after the send mediator in the inSequence I thought I can roll back the transaction in the inSequence. But this does not work either. The switch case in inSequence is called before the property is set up in JmsRollbackSequence so when I read it it always returns null.

だから私の質問は:

1) 設定できますか

順番に?JmsRollbackSequence で機能しないのはなぜですか?

2) メディエータは順番に呼び出されることになっているのに、JmsRollbackSequence が応答を読み取って JMSERROR プロパティを設定する前に inSequence の switch ケースが実行されるのはなぜですか?

4

1 に答える 1