如需使用最新稳定版本,请使用 Spring Integration 7.0.4spring-doc.cadn.net.cn

轮询入站通道适配器

概述

版本 5.0.1 引入了轮询通道适配器,允许按需获取单条消息——例如,配合 MessageSourcePollingTemplate 或轮询器使用。 请参阅 延迟确认的可轮询消息源 以获取更多信息。spring-doc.cadn.net.cn

当前不支持 XML 配置。spring-doc.cadn.net.cn

以下示例展示了如何配置一个 AmqpMessageSourcespring-doc.cadn.net.cn

@Bean
public IntegrationFlow flow() {
    return IntegrationFlow.from(Amqp.inboundPolledAdapter(connectionFactory(), DSL_QUEUE),
                    e -> e.poller(Pollers.fixedDelay(1_000)).autoStartup(false))
            .handle(p -> {
                ...
            })
            .get();
}
@Bean
public AmqpMessageSource source(ConnectionFactory connectionFactory) {
    return new AmqpMessageSource(connectionFactory, "someQueue");
}

查看Javadoc以获取配置属性。spring-doc.cadn.net.cn

XML
This adapter currently does not have XML configuration support.

批处理消息

对于轮询适配器,不存在监听器容器,批量消息始终会被解包(如果BatchingStrategy支持此操作)。spring-doc.cadn.net.cn