Global erroChannel service activator not invoked

馋奶兔 提交于 2019-12-11 13:14:31

问题


I have written an service activator for global errorChannel.

<!-- global default exception handler--> 
<int:service-activator input-channel="errorChannel" 
      auto-startup="true" ref="defaultExeptionHandler" >
</int:service-activator>

Test class

@Test
public void testTradeAcceptanceFlow() throws Exception {
    throw new FileNotFoundException();
}

Since I am explicitly throwing error, I was hoping that this would get caught in the global error channel and will in turn call my handler, which it is not doing. Any idea as to why?


回答1:


An exception is wrapped to the ErrorMessage and sent to the global (default) errorChannel if you have some async handoff in your flow.

Please, see more info in the Reference Manual.

There is a note:

The most important thing to understand here is that the messaging-based error handling will only apply to Exceptions that are thrown by a Spring Integration task that is executing within a TaskExecutor. This does not apply to Exceptions thrown by a handler that is operating within the same thread as the sender (e.g. through a DirectChannel as described above).

Many guys are missing this standard Java try...catch bahaviour in the Spring Integration and try to treat everything with that errorCnannel.

Regarding your test-method. It is fully does not make sense and does not get deal with any Spring Integration stuff.



来源:https://stackoverflow.com/questions/29226438/global-errochannel-service-activator-not-invoked

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