当前位置: 首页 > 知识库问答 >
问题:

WsO2 ESB 4.7.0中的JMS回滚

靳富
2023-03-14
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个答案

公羊雅达
2023-03-14

“Send”mediator是异步的:inSequence将继续他的工作,并且在响应到达JMSRoolBackSequence之前提交JMS事务。

同步调用使用“callout”中介器,并在代理中创建faultSequence来处理错误并回滚事务:

<faultSequence>
  <property name="SET_ROLLBACK_ONLY" value="true" scope="axis2"/>
</faultSequence>
 类似资料:
  • 密码 考虑以下情况... 事务已启动(使用Spring@Transactional annotation) 消息丢失了吗? 如果不是,那么如何在事务下从队列中读取消息(步骤2)? 是否使用了某种队列浏览器,以便从队列中读取消息但不消费?

  • 我有一个JMS监听器,与这里的监听器类似: 使用JMS模板和Spring Boot的同步消息发送和接收 它接收一个XML有效负载。但与那个不同,我还想返回一个回复。如果我返回一个字符串,它可以正常工作,但正如我对消息有效负载所做的那样,我想返回一个JAXB对象。 然而,如果我返回消息,Spring会尝试使用SimpleMessageConverter转换对象。 如何配置转换回复有效负载时要使用的M

  • 我对骆驼很陌生,如果这很明显,请原谅。 我们正在尝试设置一条骆驼路线(在 talend esb 中),它执行以下操作: < li >通过JMS接收消息 < li >数据库更新 < li >通过JMS使用请求/回复将消息发送到另一个系统 < li >使用回复中的信息进行另一次数据库更新 这一切都在一条路线上。我发现该路由不再接受 1 中的任何消息。当它正在等待 3 中的回复时。 我曾尝试在JMS组件

  • 在通过MQ处理消息时,我想有条件地回滚XA事务并将MQ消息放回原始队列。 失败将被记录到数据库中,并且可以使用基于消息类型和错误的自定义逻辑从数据库中重试。 如果我们无法将错误记录到数据库中,则应回滚整个XA事务并将消息放回队列中。 每条消息都经过多个步骤处理,代码可以处理消息的重新提交/复制。 我有一个解决方案,但它的结果是在丑陋的配置,我想知道是否有更好的方法来实现同样的结果?我在考虑使用一个

  • 我的流使用基于cron表达式的消息,我故意添加了一个groovy代码来抛出异常以测试JMS回滚。回滚不会将消耗的消息返回队列中。我在这里错过了什么吗? 这里是mule流,它应该在遇到异常后回滚mule消息。 这是此流引发的异常-

  • 我试图在camel中获取请求/回复jms消费者,收到了传入消息,我可以看到camel也发送了回复,但消息没有被封送。 我正在使用拦截器封送所有来自activemqendpoint的消息 (我扩展了JacksonDataFormat,以便在封送消息时填充JMSType。) 对于正常的单向交换,这是可行的(例如) 但是当我走这条路的时候 并将带有JMSReplyTo消息的消息发送到测试队列(使用act