Search code examples
springspring-integrationspring-integration-dsl

How to specify different errorChannels for different parts of an IntegrationFlow


I'm currently working on a Spring Integration DSL project and I've a flow that requires handling errors differently depending on the part of the flow that fails.

My current approach was to create subFlows by chaining .gateway methods, but I'm having trouble handling exceptions as the .gateway hangs indefinetly waiting for a reply after sending the message to the defined .errorChannel, which isn't required for my case, even when I configure it as .requireReply(false).

Is there any other better approach to divide the flow and handle exceptions conditionally? Could .gateways be configured to cut the flow and call postSend so channels are available after sending a message to the .errorChannel?


Solution

  • As long as only direct channels (default) are used, you can simply set the gateway reply timeout to 0, which will prevent the thread from hanging after an error has been "consumed".