问题描述
我在Spring Integration应用程序中捕获异常时遇到问题.
I have a problem in catching the exceptions in my spring integration application.
我的应用程序中的操作流程.
Flow of operations in my application.
- Http:接收请求的入站网关(错误通道定义到我的自定义错误通道)
- 用于基本验证的服务激活器(从此处引发的异常由GW上定义的错误通道处理)
- 分割器
- 聚合器
我的错误通道未处理拆分器或聚合器上的异常.为什么?
Exceptions on my splitter or Aggregator are not handled by my error channel. why?
已采取的步骤:
我添加了一条链,并包含一个头扩充器,并在拆分器之前指定了一个错误通道.
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>
- 但是在Aggregator上执行相同操作时,此操作无效.为什么?
- 只要我的代码中有异常,它就会重试并被执行多次.为什么?
-
我定义了一个"errorChannel",用于记录异常.它不起作用.
- But the same doesnt work when do the same on my Aggregator. why?
- Whenever there is an exception in my code, it retries and gets executed more than one time. why?
I have a "errorChannel" defined which logs the exceptions. it doesnt work.
推荐答案
我知道线程太旧了,但是我也遇到了类似的问题,发现我在header-enricher中声明了错误通道,但未提供'overwrite = "true"'作为参数.在提供"overwrite ="true"之后,它可以根据需要工作.令我惊讶的是,为什么Spring集成默认情况下不提供overwrite = true.
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.
这篇关于春季整合|服务激活器-错误通道,异常处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!