0

I'm trying to upgrade a project using Spring Integration 4.3 and Spring Boot 1.6 to Spring Integration 5.1 and Spring Boot 2.1. Previously I had the following configuration:

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();

During the upgrade process I've tried to follow the documentation here and thus changed the configuration to this:

@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();
    }
}

But when I publish messages it doesn't seem like they're received/handled by the integration flow. I get no error logs (or any logs at all for that matter even though I enable debug logging) and I'm not quite sure where to start debugging. I'm positive that the messages are actually published to RabbitMQ so that's not the problem. What could I be missing?

Johan
  • 37,479
  • 32
  • 149
  • 237

1 Answers1

2

My problem was actually not due to Spring Integration, rather it had to do with changes in Spring AMQP. Previously "declarables" could be created like this:

@Bean
List<Binding> myBinding() {
    return List.of(<binding1>, <binding2>, ..)
}

but in Spring AMQP 2.1 this should be changed to:

@Bean
Declarables myBinding() {
    return new Declarables(List.of(<binding1>, <binding2>, ..))
}

See documentation here.

Btw, my releaseExpression was also wrong, it should be size() eq one.payload.batchSize.

Johan
  • 37,479
  • 32
  • 149
  • 237
  • 1
    You can use `releaseStrategy(ReleaseStrategy releaseStrategy)` as a lambda for more Java code context and readability. – Artem Bilan Apr 30 '19 at 13:31