在WSO2 ESB 4.7.0中,我们可以按接收顺序进行JMS回滚吗? [英] In WSO2 ESB 4.7.0 can we do JMS rollback in receiving sequence?

查看:99
本文介绍了在WSO2 ESB 4.7.0中,我们可以按接收顺序进行JMS回滚吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在WSO2 ESB 4.7.0中用事务和CLIENT_ACKNOWLEDGE配置了Apache ActiveMQ. axis2.xml配置为:

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>

我有一个带有jms传输的简单直通代理,它将JMS队列中的消息传递给jax-rs服务.代理代码是:

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>

JmsRollbackSequence序列从jax-rs服务接收回复,并且根据返回的成功或失败,我想回滚JMS事务.但是如果我设置属性 在JmsRollbackSequence中,它完全没有作用(在使用下面显示的序列之前,我先尝试了它).交易永远不会回滚.仅当在inSequence中设置了属性时,回滚才有效. 这是JmsRollbackSequence的代码:

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>

因此,我尝试在JmsRollbackSequence中设置一个名为JMSERROR的属性,并在inSequence中的发送介体之后读取该属性,以为我可以在inSequence中回滚事务.但这也不起作用. inSequence中的switch case在JmsRollbackSequence中设置属性之前被调用,因此当我读取它时,它总是返回null.

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)我们可以设置

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

按顺序?为什么在JmsRollbackSequence中不起作用?

in a sequence? Why does it not work in JmsRollbackSequence?

2)由于应该依次调用调解器,为什么inSequence中的switch情况在JmsRollbackSequence有机会读取答复并设置JMSERROR属性之前运行?

2) As mediators are supposed to be called sequentially, why does the switch case in inSequence run before the JmsRollbackSequence has a chance to read the reply and set up the JMSERROR property?

推荐答案

我相信您只能从同一序列或与之关联的故障序列中控制事务.但是WSO2文档并没有对此说什么……

I believe you can only control a transaction from within the same sequence or the fault sequence associated with it. But the WSO2 documentation doesn't really say anything about this...

关于您的第二个问题:发送调解器是无阻塞,即以下调解器将在发送调解器返回之前执行.如果希望它等待响应,则需要使用标注中介器.然后,您可以评估响应并根据需要进行回滚(全部在inSequence内部).

Regarding your second question: The send mediator is non-blocking, i.e. the following mediators will be executed before the send mediator has returned. If you want it to wait for the response, then you need to use the callout mediator instead. Then you can evaluate the response and do the rollback if needed (all inside the inSequence).

这篇关于在WSO2 ESB 4.7.0中,我们可以按接收顺序进行JMS回滚吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆