我正在尝试将使用Spring Integration 4.3和Spring Boot 1.6的项目升级到Spring Integration 5.1和Spring Boot 2.1。以前我有以下配置:
IntegrationFlows.from(Amqp.inboundAdapter(connectionFactory, "queueName")
.id("myId")
.autoStartup(autoStartup)
.prefetchCount(10)
.concurrentConsumers(2)
.maxConcurrentConsumers(3)
.messageConverter(messageConverter()))
.aggregate(a -> a.correlationExpression("payload.entityId")
.releaseExpression("size() eq iterator().next().payload.batchSize")
.sendPartialResultOnExpiry(true)
.groupTimeout(2000)
.expireGroupsUponCompletion(true)
.outputProcessor(myMessageGroupProcessor))
.handle(serviceActivatorBean, "myMethod", e -> e.advice(requestHandlerRetryAdviceForIntegrationFlow()))
.get();
在升级过程中,我尝试遵循文档here,因此将配置更改为:
@Configuration
@EnableAutoConfiguration
@EnableIntegration
public class SpringConfig {
@Bean(name = "myFlowId")
public IntegrationFlow myFlow(ConnectionFactory connectionFactory, ServiceActivatorBean serviceActivatorBean,
@Value("${spring.integration.flow.auto-startup:true}") boolean autoStartup,
MyMessageGroupProcessor myMessageGroupProcessor) {
IntegrationFlows.from(Amqp.inboundAdapter(connectionFactory, "queueName")
.id("myId")
.autoStartup(autoStartup)
.configureContainer(c -> c.acknowledgeMode(MANUAL)
.prefetchCount(10)
.concurrentConsumers(2)
.maxConcurrentConsumers(3)
)
.messageConverter(messageConverter()))
.aggregate(a -> a.correlationExpression("payload.entityId")
.releaseExpression("size() eq one().payload.batchSize")
.sendPartialResultOnExpiry(true)
.groupTimeout(2000)
.expireGroupsUponCompletion(true)
.outputProcessor(myMessageGroupProcessor))
.handle(serviceActivatorBean, "myMethod", e -> e.advice(requestHandlerRetryAdviceForIntegrationFlow()))
.get();
}
}
但是,当我发布消息时,集成流程似乎并没有收到/处理它们。我没有错误日志(即使启用了调试日志,也没有任何日志),而且我不太确定从哪里开始调试。我很肯定消息实际上已经发布到RabbitMQ,所以这不是问题。我可能会缺少什么?
答案 0 :(得分:2)
我的问题实际上并非归因于Spring Integration,而是与Spring AMQP中的更改有关。以前可以这样创建“声明的”:
@Bean
List<Binding> myBinding() {
return List.of(<binding1>, <binding2>, ..)
}
但是在Spring AMQP 2.1中,应将其更改为:
@Bean
Declarables myBinding() {
return new Declarables(List.of(<binding1>, <binding2>, ..))
}
请参阅文档here。
顺便说一句,我的releaseExpression
也错了,应该是size() eq one.payload.batchSize
。