You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Spring Integration 5.5.18中<int:router>内<int:poller>配置报错及轮询方案咨询

问题

原本基于spring-integration 2.3.0.RELEASE开发的应用,<int:router>配置内嵌套<int:poller>可以正常运行,示例配置如下:

<int:router id="channelRouter" input-channel="exceptionChannel"
        expression="@system.getId(payload)">
    <int:mapping value="0" channel="exceptionChannel0" />
    <int:mapping value="1" channel="exceptionChannel1" />
    <int:poller fixed-rate="10" task-executor="sysExecutor" />
</int:router>

<task:executor id="sysExecutor"
        pool-size="1" queue-capacity="1" rejection-policy="DISCARD" />

升级到spring-integration 5.5.18后,出现XML解析错误,错误提示<int:poller>是无效内容,该错误在通过ClassPathXmlApplicationContext加载XML配置文件时触发,加载代码如下:

AbstractApplicationContext context = new ClassPathXmlApplicationContext("/META-INF/spring/integration/helloWorldDemo.xml", HelloWorldApp.class);

请问是否需要从<int:router>中移除<int:poller>?如果需要移除,没有poller时路由器该如何轮询输入通道?

回答

  • 必须移除<int:router>内部的<int:poller>配置。Spring Integration从3.0版本开始就调整了poller的配置规则,不再允许在路由器这类消息处理器内部直接配置poller,poller需要绑定到消息通道而不是处理器上。
  • 移除后,要实现对输入通道的轮询,需要将poller配置到输入通道exceptionChannel上,具体是把该通道定义为pollable-channel并附加poller配置:
<int:pollable-channel id="exceptionChannel">
    <int:poller fixed-rate="10" task-executor="sysExecutor" />
</int:pollable-channel>
  • 路由器本身只负责消息的路由逻辑,轮询动作由绑定到输入通道的poller来执行。当poller从exceptionChannel拉取到消息后,会自动将消息交给路由器处理,完全能实现你原本的业务逻辑。

内容的提问来源于stack exchange,提问作者Mani kandan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.17 18:43:24