【问题标题】:Mule not rolling back JMS message after exception异常后骡子不回滚JMS消息
【发布时间】:2013-04-11 01:21:52
【问题描述】:

我的流程使用基于 cron 表达式的消息,并且我特意添加了一个 groovy 代码来抛出异常以测试 JMS 回滚。回滚不会将已使用的消息返回到队列中。我在这里错过了什么吗?

这里是 mule 流程,它应该在遇到异常后回滚 mule 消息。

<jms:activemq-connector name="jmsConnector" specification="1.1" brokerURL="tcp://localhost:61616" />
<jms:endpoint name="testqueue" queue="test.queue" connector-ref="jmsConnector" />

<flow name="quartzBasedDelivery">
    <quartz:inbound-endpoint jobName="deliveryJob" cronExpression="0 0/1 * * * ?">
        <quartz:endpoint-polling-job>
            <quartz:job-endpoint ref="testqueue" />
        </quartz:endpoint-polling-job>
    </quartz:inbound-endpoint>
    <logger message="QUARTZ found message for delivery #[payload]" level="INFO" />
    <scripting:component>
               <scripting:script engine="groovy">
                    throw new java.lang.RuntimeException();
                </scripting:script>
    </scripting:component>
    <file:outbound-endpoint path="/test/out" outputPattern="message-[function:dateStamp].txt" />
    <logger message="Message deliverd" level="INFO" />
</flow>

<flow name="copyFile">
    <file:inbound-endpoint  path="/test/in"/>
    <byte-array-to-string-transformer /> 
    <logger message="COPYFILE found message for test queue #[payload]" level="INFO" />
    <jms:outbound-endpoint queue="test.queue"/> 
</flow>

这是这个流程抛出的异常 -

    Exception stack is:
1. null (java.lang.RuntimeException)
  sun.reflect.NativeConstructorAccessorImpl:-2 (null)
2. java.lang.RuntimeException (javax.script.ScriptException)
  org.codehaus.groovy.jsr223.GroovyScriptEngineImpl:323 (http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/script/ScriptException.html)
3. Failed to invoke ScriptComponent{quartzBasedDelivery.component.559022270}. Component that caused exception is: ScriptComponent{quartzBasedDelivery.component.559022270}. Message payload is of type: String (org.mule.component.ComponentException)
  org.mule.component.AbstractComponent:148 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/component/ComponentException.html)
********************************************************************************
Root Exception stack trace:
java.lang.RuntimeException
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)

【问题讨论】:

  • 你在哪里配置了事务和回滚异常策略?
  • @Seba 默认异常策略回滚事务。所以,即使我没有提到回滚策略……它是隐含的。

标签: jms mule


【解决方案1】:

在您的情况下,Rollback Exception Strategy 不会将 JMS 消息重新传递到原始队列,因为您有一个 Quartz 入站端点,它不是事务性的或可靠的。 您可以配置Catch Exception Strategy 并明确重新传递消息。请注意这些情况,因为您可以创建无限循环。

来源: Rollback Exception Strategy

HTH

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-09-03
    • 2015-02-25
    • 1970-01-01
    • 2020-09-17
    • 2016-03-18
    • 2016-10-10
    • 2015-11-27
    相关资源
    最近更新 更多