繁体   English   中英

WsO2 ESB 4.7.0中的JMS回滚

[英]JMS rollback in WsO2 ESB 4.7.0

 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)由于应该按顺序调用中介程序,所以为什么inSequence中的switch情况在JmsRollbackSequence有机会读取回复并设置JMSERROR属性之前运行?

“发送”介体是异步的:inSequence将继续其工作,并且JMS事务将在响应到达您的JmsRoolbackSequence之前提交。

使用“调出”调解器进行同步调用,并在代理中创建faultSequence以处理错误并回滚事务:

<faultSequence>
  <property name="SET_ROLLBACK_ONLY" value="true" scope="axis2"/>
</faultSequence>

暂无
暂无

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

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