Contact Us 1-800-596-4880

Synchronous Versus Asynchronous Aggregations

An aggregation is complete based on a new element added to the list, as when a max size is specified, or because some timeout or time period is complete. This is important because the type of aggregation determines which chain of components to execute with the list of elements. There are two kinds of triggers for an aggregation completion: synchronous and asynchronous.

Each time counter associated with an aggregator starts counting from the moment the first message of a group arrives. Once the aggregation is complete, the counter resets and waits for the next element to arrive.
For single-group aggregators (time-based and size-based aggregators scopes), there is only one time counter, but for the group-based aggregator, there is one counter per group.

Synchronous Aggregations

For aggregations completed because a new element arrives (Sync), at least one of the following things occur:

  • If the aggregator scope is configured with an Aggregation complete route, the components inside that route execute with the payload being the list of aggregated elements.

  • If the aggregator scope has a referenced Aggregator listener, the flow to which that listener belongs executes with the payload being the list of aggregated elements.

Asynchronous Aggregations

For aggregations completed because a time period ended or a timeout was reached (Async), the only thing that can happen is that if the aggregator scope has a referenced Aggregator listener and the listener accepts timed-out aggregations, the flow to which that listener belongs executes the list of aggregated elements as the payload.

Placement of Processing Logic for Mule Apps Using Aggregators

When you create a Mule app that uses aggregators, place the processing logic as follows:

  • If the aggregation depends on time, add the processing logic in a different flow with an Aggregation listener as a source.

  • If the aggregation depends on a size being reached, add the processing logic in the Aggregation complete route.

  • If the aggregation depends on both time and size:

    • Add the main logic in a subflow with no source. The Is aggregation complete attribute shows how the aggregation ended.

    • Add a Flow reference component to the main logic flow in the Aggregation complete route. If the subflow is executed by this flow reference, then the Is aggregation complete attribute is true.

    • Add another flow with an Aggregation listener that listens to the aggregator and accepts timed-out groups. Follow the listener with a Flow reference component that calls the main logic subflow. In this case, the Is aggregation complete attribute is false.

View on GitHub