我是Mule ESB的新手.我创建了一个循环遍历订单列表的简单流程,并调用Magento API逐个更新订单状态.我的问题是,如果foreach范围中发生任何异常,整个过程最重要.我尝试使用异常策略来捕获异常,它确实捕获了异常.但是如何恢复这个过程呢?我没有找到谷歌搜索的太多信息.也许我在流程上做错了.我们如何正常处理骡子?
这是我在xml中的流程.
<flow name="Update_Magento_Order_Status_AU" doc:name="Update_Magento_Order_Status_AU" initialState="started">
<poll doc:name="Poll">
<fixed-frequency-scheduler frequency="10" timeUnit="MINUTES"/>
<jdbc-ee:outbound-endpoint exchange-pattern="request-response" queryKey="GET_ORDERS_BY_STATUS_QUERY" queryTimeout="-1" connector-ref="DSEDatabase" doc:name="Get Orders By Status"/>
</poll>
<flow-ref name="ProcessOrderStastusUpdate" doc:name="Process Order Status Update"/>
</flow>
<flow name="ProcessOrderStastusUpdate" doc:name="ProcessOrderStastusUpdate">
<foreach collection="#[payload]" doc:name="For Each">
<component doc:name="Set Magento Order Status for Update">
<singleton-object class="com.dse.esb.component.OrderStatusMapperComp">
<property key="as400OrderStatuses" value="${as400.orderstatuses}"/>
<property key="magentoOrderStatuses" value="${magento.orderStatuses}"/>
</singleton-object>
</component>
<logger message="About to update Magento Order Status" level="INFO" doc:name="Logger"/>
<magento:add-order-comment config-ref="Magento" comment="Updated by Mule ESB with AS400 order status: #[payload.TRNSTS]" orderId="#[payload.EPGORDNBR]" status="#[flowVars['magentoOrderStatus']]" doc:name="Update Magento Order Status"/>
</foreach>
<choice-exception-strategy doc:name="Choice Exception Strategy">
<catch-exception-strategy doc:name="default">
<logger message="Handle default exception" level="INFO" category="==============>>>>>>>>>>>>" doc:name="Logger"/>
</catch-exception-strategy>
</choice-exception-strategy>
</flow>
最佳答案 使用私有流为for-each的内容提供自己的异常策略.异常将在私有流中处理,父流应该能够继续.就像是:
<flow name="ProcessOrderStastusUpdate">
<foreach collection="#[payload]" doc:name="For Each">
<flow-ref name="privateFlow" />
</foreach>
</flow>
<flow name="privateFlow">
<component doc:name="Set Magento Order Status for Update">
<singleton-object class="com.dse.esb.component.OrderStatusMapperComp">
<property key="as400OrderStatuses" value="${as400.orderstatuses}"/>
<property key="magentoOrderStatuses" value="${magento.orderStatuses}"/>
</singleton-object>
</component>
<logger message="About to update Magento Order Status" level="INFO" doc:name="Logger"/>
<magento:add-order-comment config-ref="Magento" comment="Updated by Mule ESB with AS400 order status: #[payload.TRNSTS]" orderId="#[payload.EPGORDNBR]" status="#[flowVars['magentoOrderStatus']]" doc:name="Update Magento Order Status"/>
<choice-exception-strategy doc:name="Choice Exception Strategy">
<catch-exception-strategy doc:name="default">
<logger message="Handle default exception" level="INFO" category="==============>>>>>>>>>>>>" doc:name="Logger"/>
</catch-exception-strategy>
</choice-exception-strategy>
</flow>