2

I'm having an issue with my Spring Boot app where the only one group is processed in my aggregator and then the app stops consuming more messages from the queue. It only processes a group at startup it seems. I restarted the app and it processed another group, but then it just stopped again.

This is my flow below.

return IntegrationFlows.from(Amqp.inboundAdapter(connectionFactory, importQueueName).errorChannel(errorChannel))
                .split(userImportSplitter)
                .channel(Amqp.channel(connectionFactory)
                        .queueName(USER_QUEUE_NAME)
                        .prefetchCount(batchSize))
                .aggregate(a -> a.releaseStrategy(g -> g.size() >= batchSize)
                        .sendPartialResultOnExpiry(true)
                        .groupTimeout(500))
                .handle(userImporter)
                .get();
Ivan
  • 31
  • 4

1 Answers1

1

Probably your userImportSplitter produces the same conrrelationId, therefore only one group is formed in the aggregator and by default it is not removed after release or timeout.

Consider to use these options:

.aggregate(a -> a.releaseStrategy(g -> g.size() >= batchSize)
                    .sendPartialResultOnExpiry(true)
                    .groupTimeout(500)
                    .expireGroupsUponCompletion(true)
                    .expireGroupsUponTimeout(true))
Artem Bilan
  • 113,505
  • 11
  • 91
  • 118
  • Still doing the same thing. – Ivan Jun 29 '20 at 13:49
  • Can we see what's your `userImportSplitter` is doing? How does it work if you remove that ` .channel(Amqp.channel()` in between? – Artem Bilan Jun 29 '20 at 13:51
  • Figured it out. It was an issue with the `userImporter` throwing an exception. I guess my new question is how do I keep that message from blocking the queue? – Ivan Jun 29 '20 at 14:14
  • See `ExpressionEvaluatingRequestHandlerAdvice`: https://docs.spring.io/spring-integration/docs/current/reference/html/messaging-endpoints.html#message-handler-advice-chain. The splitter is just a loop and it fails same way if you would fail in the plain Java `for()` loop. So, to prevent premature exit from the loop we need to `try..catch` that internal exception and do something with the failed item. – Artem Bilan Jun 29 '20 at 14:26