Tuesday, March 22, 2016

[ESB] Aggregate Responses with WSO2 Aggregate Mediator




Aggregate mediator can be used to merge several responses and create one response by matching the Xpaths.
In this blog post I'm going to demonstrate how to aggregates the response messages which were split by Iterator Mediator. 

The flowing proxy wrote to get the GitHub Contributors details for a specified repository.

 
The response message of this proxy is as shown below.


But the expected response message is as shown below.

 
Solution :

To get the expected response message  need to merge the sub messages in to one. We can do this using Aggregate Mediator.

To do this  need to add the Aggregate Mediator inside the out sequence as shown in below figure.

 

In the aggregate mediator we need to add the following parameters.

Aggregate Id : you can give any proper Id . This parameter is an optional thing

Aggregation Expression : This is the Xpath expression specifying based on which elements to aggregate.

Completion Max-messages : -1
Completion Min-messages : -1

There are maximum and minimum number of messages that can exists in aggregation . Here I used both cases as -1 because I need to aggregate all the messages.

EnclosingElementProperty : This is used to accumulate the aggregated messages inside single property.
Here I used this as “ROOT”. This property need to define in the proxy as follows.

<property name="ROOT" scope="default">
<root xmlns=""/>
</property>


No comments:

Post a Comment