Search code examples
spring-integrationspring-integration-dsl

Execute a method after all messages are put to kafka in spring cloud integration flow after split


How can I execute a method after all the messages are put on to Kafka after split.

I have tried using handle() after channel, but that ends up not posting from 2nd message on to Kafka.

 IntegrationFlowBuilder flowBuilder = IntegrationFlows
        .from(() -> jdbcTemplate....);
 flowBuilder.split();
 flowBuilder.channel(messageChannel);

I would like to execute a method after writing all the split messages to Kafka.


Solution

  • Since you split and only after that send to the Kafka, there is no way to catch all of them, unless aggregate afterwards. You can do that with the publishSubscribeChannel to send to the Kafka and aggregator the same message. When aggregator releases a group, you are good to perform your method call.