How to add a global exception handler/logger once in Mule

霸气de小男生 提交于 2020-01-14 12:37:13

问题


We want to add a few lines of XML config to mule with an exception handler that logs to SLF4J instead of where they log right now (stdout). How do we add this?

We do NOT want to have to add this handler to every single flow (50+ flows, plus as people add flows, they may forget to add our exception handler).


回答1:


This is an example of "how to share a common exception handler across flows" (in this case a catch-exception-strategy):

<catch-exception-strategy name="myGlobalCatchStrategy">
    <set-payload value="Hey something happened! : #[exception.getSummaryMessage()]" />
</catch-exception-strategy>

<configuration defaultExceptionStrategy-ref="myGlobalCatchStrategy" />

<flow name="global-catch-example">

    <inbound-endpoint address="vm://entry-point.in" exchange-pattern="request-response" />

    <test:component throwException="true" />

</flow>


来源:https://stackoverflow.com/questions/9296549/how-to-add-a-global-exception-handler-logger-once-in-mule

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!