Spring integration | Service Activator - Error Channel , Exception handling

早过忘川 提交于 2019-12-13 02:27:08

问题


I have a problem in catching the exceptions in my spring integration application.

Flow of operations in my application.

  1. Http:inbound gateway which receives the request (error-channel defined to my custom error channel)
  2. Service Activator for basic validations (Exceptions which are thrown from here are handled by error-channel defined on the GW)
  3. splitter
  4. Aggregator

Exceptions on my splitter or Aggregator are not handled by my error channel. why?

Steps taken:

I added a chain and included a header enricher and specified an error channel just before the splitter.

After this, any exception on my splitter is handled by my error channel mentioned in the header enricher.

<chain input-channel="invitations">
        <header-enricher>
            <error-channel ref="failed-invitations" />
        </header-enricher>
        <int:splitter ref="payloadSplitter" />
    </chain>
  1. But the same doesnt work when do the same on my Aggregator. why?
  2. Whenever there is an exception in my code, it retries and gets executed more than one time. why?
  3. I have a "errorChannel" defined which logs the exceptions. it doesnt work.



回答1:


I know the thread is too old, but I was also facing a similar issue and found I declared error-channel in header-enricher but not provide 'overwrite="true"' as a parameter. And after providing 'overwrite="true"'it is working as needed. I am surprised why spring integration does not provide an overwrite=true by default.

Let us know this is what solution you did in your old code? So everyone can find out the solution for such a scenario.



来源:https://stackoverflow.com/questions/27387988/spring-integration-service-activator-error-channel-exception-handling

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