Search code examples
spring-integrationspring-integration-dsl

How to handle integration flows that terminated in transit


How do we handle below flow, when it terminates (may be server dies while one of the transformation was in progress)?

@Bean
public IntegrationFlow sampleFlow() {
    return IntegrationFlows.from(httpAdapters.pushInbound())
            .transform(transformer1)
            .transform(transformer2)
            .handle(messageHandler1)
            .get();
}

Is there any way, that when we restart the springboot application that the flow continues from where it left off? What is the best way to go about it?

Given that, we are trying to push data from system1 -> system2. And that system 1 does a rest api call (http call) to the spring integration.


Solution

  • The best way to do that is to persist messages in between flow steps.

    For this purpose we provide a QueueChannel and ChannelMessageStore with various implementations for target databases: https://docs.spring.io/spring-integration/docs/current/reference/html/system-management-chapter.html#message-store

    Of course, the best way is to use a transactional store to have automatic roll backs when you fail. So, the next time your flow will pull messages from the store to process.