如何从mule中的catch-exception-strategy重新抛出异常。
尝试使用以下流程并在" flowdemo"之后发生异常。错误处理,它没有进行错误处理mdemoflow。它执行在flow-ref之后放置的记录器。
<mule ....>
<sub-flow name="exceFlow">
<logger level="ERROR" doc:name="Logger"/>
<expression-component doc:name="Expression"><![CDATA[throw new java.lang.IllegalArgumentException('bad arg');]]></expression-component>
<validation:is-true expression="false" doc:name="Validation"/>
<scripting:component doc:name="Script">
<scripting:script engine="Groovy"><![CDATA[throw new java.lang.IllegalArgumentException('bad arg')]]></scripting:script>
</scripting:component>
<logger level="INFO" doc:name="Logger"/>
</sub-flow>
<flow name="flowdemo" processingStrategy="synchronous">
<expression-component doc:name="Expression"><![CDATA[flowVars.dummy = flowVars.fake.test]]></expression-component>
<catch-exception-strategy doc:name="Catch Exception Strategy" >
<flow-ref name="exceFlow" doc:name="Flow Reference"/>
</catch-exception-strategy>
</flow>
<flow name="mdemoFlow" processingStrategy="synchronous">
<poll doc:name="Poll">
<fixed-frequency-scheduler frequency="3" timeUnit="MINUTES"/>
<logger level="INFO" doc:name="Logger"/>
</poll>
<flow-ref name="flowdemo" doc:name="flowdemo"/>
<logger level="INFO" doc:name="Logger"/>
<catch-exception-strategy doc:name="Catch Exception Strategy">
<logger message="test logging in error" level="ERROR" doc:name="Logger"/>
<logger level="INFO" doc:name="Logger"/>
</catch-exception-strategy>
</flow>
</mule>
答案 0 :(得分:0)
flowdemo是flow(不是子流)并且有自己的catch异常Stratergy(所以它由demo流本身处理)。线程从主流(mdemoFlow)开始,它通过flowRef调用其他流,因此它返回到mainFlow以完成预期的线程(无论流处理策略如何)。如果要处理主流本身中的所有异常。请使用下面的配置(将flowdemo设为子流),因此默认情况下,在其关联的子流中发生的任何异常都将返回其主流以处理相同的事件。
SELECT [ProductName], [PricePerPiece], [CafeID],
SUM([Quantity]) AS [Quantity], SUM([TotalPrice]) AS [TotalPrice],
[MemberID], [ProductID]
FROM [ProductOrders]
GROUP BY [ProductID], [ProductName], [PricePerPiece], [CafeID], [MemberID];
将异常策略设为全局。您可以使用全局异常策略并通过引用异常策略调用相同的策略。有关详细信息,请参阅该链接https://docs.mulesoft.com/mule-user-guide/v/3.7/reference-exception-strategy