1
votes

I have an integration flow like below and I would like to add a retry for whole the integration flow. Like for any exception in the flow, we do retry and when retries exhausted send it to dead-letter queue.

IntegrationFlows
        .from(kinesisInboundChannelAdapter(amazonKinesis(), streamNames))
        .transform(new IssuanceTransformer())
        .route(router())
        .get(); 

Would you please help me out how to configure both retries and dead-letter queue?

Thank you

1

1 Answers

0
votes

Your understanding of integration flow and retry is slightly wrong. The retry it applied for some service call. When we have a complex flow like yours we have also channels between service calls. So, what you can do is something like a retry for each component you think is wrong. For that purpose you need to take a look into the RequestHandlerRetryAdvice and an advice() option of the ConsumerEndpointSpec.

If you really have all the logic in a single thread and the same call stack, we really can come up with the solution like "retry the whole sub-flow", but from the Spring Integration perspective it still looks like a service call. For this purpose you need to take a look into the .gateway() EIP-method of the IntegrationFlowDefinition:

IntegrationFlows
    .from(kinesisInboundChannelAdapter(amazonKinesis(), streamNames))
    .gateway(sf -> sf
            .transform(new IssuanceTransformer())
            .route(router())
        , e -> e.advice(requestHandlerRetryAdvice()))
    .get();