---
schema_version: "1"
id: 1c4a538b74927c0ded99d2b23ea4b00875eea2e2f77d909c72bbe67f0082a4bc
title: Synchronous Versus Asynchronous Aggregations
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/aggregators-module/1.0/aggregators-sync-async.md
canonical_url: https://docs.mulesoft.com/aggregators-module/1.0/aggregators-sync-async
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 4dfe3f8b641b5f705820ef4dfd4f26c81c5a4e73dc8b71345e35da1fee106d0e
description: MuleSoft Documentation Site
release: "1.0"
latest: false
---
---
product: Aggregators Module
version: 1.0
---

# Synchronous Versus Asynchronous Aggregations

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

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.

> [!IMPORTANT] 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`.

## See Also

- [Aggregators Module Reference](https://docs.mulesoft.com/aggregators-module/1.0/aggregators-module-reference)

- [Salesforce Help](https://help.salesforce.com)
