1
votes

I have splitter message that split one original message become 3 part. And i need to send it sequentially via http outbound gateway. For instance the step is will be like this.

  1. A message called A splitted into (A1.request,A2.request,A3.request)channels
  2. A1.request send to Rest Api server and return response A1.response channel
  3. Use A1.response channel for conditional value, if it return success then send A2.request to different url.
  4. Then use A2.response channel as conditional value, if it return success then send A3.request to different url.
  5. Collect all the reply channels (A1.response,A2.response,A3.response) to construct conditional output for next step.

How the best way to achieve that? thanks in advance.

1

1 Answers

1
votes

It can be done with a series of components

  • aggregate the 3 splits into a message with the A1.request as the payload and the other requests in headers, then after the first gateway, a router, and transformer to move the A2.request to the payload etc, etc,

But the flow might get a little convoluted and hard to debug and maintain.

It would probably be easier to put the orchestration code in a simple java class and invoke each service via a messaging gateway for each http gateway.

i.e. send message A to a <service-activator/>, which has 3 gateways injected.

Split, call gateway1 (which sends the message to http1) examine the result, ..., then aggregate and return the final result.

EDIT

Something like this is what I meant...

<int:chain ...>
    <int:splitter ... />
    <int:aggregator />
    <int:header-enricher>
        <int:header name="A2" expression="payload.get(1)" />
        <int:header name="A3" expression="payload.get(2)" />
    </int:header-enricher>
    <int:transformer expression="payload.get(0)" />
</int:chain>

Then, invoke the first gateway, if successful, save the result in a header and use a

<transformer ... expression=headers['A2'] />

send to second http etc.

To test success/failure you could use a router, or a simple <filter/> with the failure going to the discard channel.