Mule ESB:什么“Jms会话应该交易”是什么意思?

时间:2015-12-12 02:53:19

标签: error-handling mule esb rollback

快速,直截了当

我正在测试JMS订阅流程中的重试逻辑。它正在抛出

org.mule.transaction.IllegalTransactionStateException: Jms session should be transacted

使用JMS ActiveMQ的管理界面(localhost:8161 / admin / topic)进行测试,向主题[流程正在订阅]发送消息。

问题:

  1. 错误是由于某些事情而引发的 配置正确吗?或
  2. 默认情况下,使用ActiveMQ的“发送到”提交消息是 非交易会话?如何让它“成交”?
  3. 详细阐述[及更长]的解释

    作为消息源,流具有JMS端点(设置为持久客户端);另外,流程配置为“多资源事务”类型;并有一个“回滚例外策略”。 该流程已被故意配置为抛出SQL错误(在主键列中插入固定值),以及“回滚异常策略”日志消息。

    以下是流程:

    - 编辑:以及JMS连接配置

    ...
        <jms:activemq-connector name="PasswordResetTuT_Durable_Client_ACK_MQ" brokerURL="tcp://localhost:61616?keepAlive=true" validateConnections="true" clientId="PASSWORDRESET" doc:name="Active MQ" durable="true" maxRedelivery="5" >
            <reconnect frequency="7000" count="30"/>
        </jms:activemq-connector>
    ...
        <flow name="PASSWORDRESET-TUT.RequestConfirmation" processingStrategy="synchronous">
            <jms:inbound-endpoint topic="/passwordreset-tut/requestConfirmation" connector-ref="PasswordResetTuT_Durable_Client_ACK_MQ" durableName="PASSWORDRESET-TUT.RequestConfirmationDurableClientName" doc:name="JMS">
                <ee:multi-transaction action="ALWAYS_BEGIN" timeout="15000"/>
            </jms:inbound-endpoint>
            <!-- ...
                    some processing goes here ...
                                                  -->
            <expression-component doc:name="Expression"><![CDATA[flowVars.token="123456789ABCDEF";]]></expression-component>
            <db:insert config-ref="PasswordReset_Database_Configuration" doc:name="Insert into TOKEN">
                <db:parameterized-query>
                    <!-- an insert statement that, due to the 
                         expression-component above, will attempt to 
                         insert a duplicate value into a primary key -->
                </db:parameterized-query>
            </db:insert>
            <!-- ...
                    some processing goes here ...
                                                  -->
            <logger message="Finished confirming #[flowVars.token]." level="INFO" doc:name="Logger"/>
            <rollback-exception-strategy maxRedeliveryAttempts="5" doc:name="Rollback Exception Strategy">
                <logger message="Exception throw. Attempting redelivery #[(message.inboundProperties.JMSRedelivered==false)?1:message.inboundProperties.JMSXDeliveryCount+1] for message #[message.outboundAttachments.JMSMessageID]." level="INFO" doc:name="Logger"/>
                <on-redelivery-attempts-exceeded>
                    <logger message="Redelivery exhausted. Sending #[message.inboundProperties.JMSMessageID] to DLQ." level="INFO" doc:name="Logger"/>
                    <jms:outbound-endpoint topic="/passwordreset-tut/DLQ/requestConfirmation" connector-ref="PasswordResetTut_MQ" doc:name="JMS"/>
                </on-redelivery-attempts-exceeded>
            </rollback-exception-strategy>
        </flow>
    ...
    

    第一次“测试尝试”是使用ActiveMQ的“发送到”[主题](http://localhost:8161/admin/topics.jsp)完成的:它抛出了上述错误。

    现在,不清楚(至少对我而言)(1)问题是由我用来测试它的方法引起的,还是(2)它是由于某些错误配置引起的[在流程中] ]

1 个答案:

答案 0 :(得分:0)

我认为这可能与设置ActiveMQ连接器的事务类型有关,如果您有重试策略,它必须是一个事务,以便保存事务并可以重试。从消息流中,如果单击JMS连接器,则应在队列和主题设置下方看到“事务”设置。对于所有入站JMS,应将其设置为始终开始,对于跟随JMS入站的任何出站,应将它们设置为始终加入。