Mule在异常后没有回滚JMS消息

时间:2013-04-18 04:06:33

标签: jms mule

我的流消耗基于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)

1 个答案:

答案 0 :(得分:4)

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

来源: Rollback Exception Strategy

HTH