小智 9
在某些情况下,exception.cause
可以null
建议使用条件来显示消息:
[(exception.cause!=null)?(exception.cause.message):exception]
Run Code Online (Sandbox Code Playgroud)
这将防止空指针异常.
你可以#[exception.causedBy]
这样做
<choice-exception-strategy>
<catch-exception-strategy when="exception.causedBy(com.company.BusinessException)"> <!-- [1] -->
<jms:outbound-endpoint queue="dead.letter">
<jms:transaction action="ALWAYS_JOIN" />
</jms:outbound-endpoint>
</catch-exception-strategy>
<rollback-exception-strategy when="exception.causedBy(com.company.NonBusinessException)"> <!-- [2] -->
<logger level="ERROR" message="Payload failing: #[payload]"/>
</rollback-exception-strategy>
</choice-exception-strategy>
Run Code Online (Sandbox Code Playgroud)
更多详情请点击这里