This documentation is for WSO2 Enterprise Service Bus version 4.7.0 . View documentation for the latest release.

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

The Aggregate Mediator implements the Message Aggregator enterprise integration pattern and aggregates the response messages for messages that were split by the Clone or Iterate mediator and sent using the Send mediator. At the same time, it can aggregate messages in the presence of matching elements specified by the correlateOn XPath expression. Aggregate collects the incoming messages until the the completion condition is satisfied. The completion condition can specify a minimum or maximum number of messages to be collected, or a timeout value in seconds, after which the aggregation terminates. Note that when the Iterate Mediator is used to split the requests and produces only an n number of fragmented messages, the Aggregate Mediator will terminate as soon as it receives n responses, even if you have specified a higher minimum limit.

On completion of the aggregation, the Aggregate mediator will merge all collected messages and invoke the onComplete sequence on it. The merged message will be created using the XPath expression specified by the attribute expression on the onComplete element.

Excerpt
hiddentrue

NOTE TO WRITERS: The following note is based on the FAQ http://docs.wso2.org/wiki/display/FAQ/Mediators#Mediators-Iterate. If you make changes to the note, be sure to make changes in the original FAQ as well.

 Note that the responses will not necessarily be aggregated in the same order that the requests were sent, even if you set the sequential attribute to true on the Iterate mediator.


Table of Contents
maxLevel3
minLevel3
styleborder:1
locationtop
typeflat
separatorpipe


Syntax

Code Block
XML
XML
<aggregate>
   <correlateOn expression="xpath"/>?
   <completeCondition [timeout="time-in-seconds"]>
     <messageCount min="int-min" max="int-max"/>?
   </completeCondition>?
   <onComplete expression="xpath" [sequence="sequence-ref"]>
     (mediator +)?
   </onComplete>
</aggregate>

UI Configuration

The Aggregate Mediator field descriptions:

  • Aggregate ID - This optional attribute can be used to aggregate only responses for split messages that are created by a specific clone/iterate mediator. Aggregate ID should be the same as the ID of the corresponding clone/iterate mediator that creates split messages. This is particularly useful when aggregating responses for messages that are created using nested clone/iterate mediators.
  • Aggregation Expression - An XPath expression specifying which elements to aggregate. A set of messages that is taken for aggregation is determined through Correlation Expression.
  • Completion Timeout - Time that the aggregator waits for messages.
  • Completion Max-messages - Maximum number of messages that can exist in an aggregation.
  • Completion Min-messages - Minimum number of messages required for the aggregation to complete.
  • Correlation Expression - An XPath expression specifying the pattern messages collected for aggregation. A specific aggregation condition is set through the Aggregation Expression.
Info
titleTip

You can click the "NameSpaces" link to add namespaces if you are providing an expression. You will be provided another panel named "Namespace Editor", where you can provide any number of namespace prefixes and URLs used in the XPath expression. 

  • On Complete:
    • Anonymous
    • Pick From Registry - The Path can be chosen from the Configuration Registry or Governance Registry. For more information, see Working with the Registry.
Info
titleNote

You can configure the Mediator using XML. Click on "switch to source view" in the "Mediator" window.


Example

Code Block
XML
XML
<outSequence>
    <aggregate>
        <onComplete expression="//m0:getQuoteResponse"
                xmlns:m0="http://services.samples">
            <send/>
        </onComplete>
    </aggregate>
</outSequence>

In this example, the Mediator aggregates the responses coming in to the ESB and on completion, it sends the aggregated message through the Send Mediator.

For more examples, see:

 

Excerpt
hiddentrue

Description of the Aggregate Mediator in WSO2 ESB.