Saturday, October 29, 2016

Aggregate multiple responses using WSO2 ESB

This blog post explains how we can aggregate multiple responses from different endpoints.
In my previous post, I explained how we can call multiple endpoints in parallel using WSO2 ESB. So in this post we are aggregating the responses we got from those service calls.

Synapse Configuration


Explanation

In this example, we have aggregated the two responses coming from our two service calls and have wrap them using My_Response tag. So your final message after the aggregation will look like below.

Note the following.
  • When aggregating we have used the same id (which is "BOOKING_RESPONSE") that we set when we are calling the two services
  • Inside "onComplete" element you can write the logic you want to perform after the aggregation. It can contain sequences or another call to an endpoint.
  • In this example we have aggregated the bodies of the two responses without any condition
  • "Aggregated_Responses" property defined before the aggregate mediator is used to accumulate the aggregated messages inside a single property. Note we have given the name of the property in the "enclosingElementProperty" tag

Apart from aggregating the responses of the service calls sent from clone mediator, we can use the aggregate mediator to aggregate responses of the service calls from iterate mediator as well.

No comments:

Post a Comment