Search code examples
spring-integrationspring-integration-dsl

spring integration - orchestrating series of rest calls


I have an use case which needs needs to do the following:

  • On receipt of a request make service call A, B, C, D and then send the response
  • Between each of the service calls, log before and after the call
  • B & C can be called after A, but D has to be called after both B & C are complete.
  • Implement a generic error channel for all error handling and send response
  • Ability to skip steps or start at a given step. Metadata to identify the step will be in request.

Currently I have implemented by having a message channel between each of the step, meaning each step receives request from its inbound channel and once it completes its task, it posts on the inbound channel of the next step. Logging before and after is achieved through wireTap.

What is the best approach?

thank you,


Solution

    1. Logging via WireTap. You got it!
    2. "generic error channel" - inbound gateway have an errorChannel option to catch all the downstream exceptions and handle them.
    3. "B & C can be called after A...". Sounds like a RecipientListRouter - so you send the same message to all the subscribed channels. Although you can use the PublishSubscribeChannel as well.
    4. Skip logic you may implement with the Filter and its reject channel. Although the router may do the trick for you as well.