IBM BPM, V8.0.1, All platforms > Programming IBM BPM > Enterprise Service Bus programming > Aggregation > Aggregation patterns

Aggregation of data from multiple sources

This scenario is based on an insurance quote comparison website that involves a web interface that allows users to specify details of their quote.

A business processing engine controls the process and submits a single request to an aggregation mediation, which submits this request to multiple insurance firms. The responses are then aggregated into a single response for the business process to manipulate before displaying the request to the user.


Design the aggregation

The input into the flow is the InsuranceQuote interface, which specifies a Quote business object with the relevant data. The first step in planning the aggregation architecture is to determine if all data required to call the subsequent services are available in the inbound message, or if message enrichment is required. In this scenario, the Quote object contains all the information for both services. If this is not the case, then use a combination of this pattern and the batch processing with message enrichment pattern.

The mediation flow includes a Fan Out mediation primitive (operating in Once mode) receiving the Quote message as input and branching the logic to each insurance back-end service (InsuranceCompanyA and InsuranceCompanyB). Before each Service Invoke mediation primitive, a Mapping mediation primitive converts the body of the message to the correct format, and immediately after the Service Invoke mediation primitive, a Message Element Setter mediation primitive stores the response within the Shared context for later retrieval when building the aggregated response. These two branches are then collected by a Fan In mediation primitive (operating in Count mode). When the second message arrives at the Fan In mediation primitive, its output terminal fires with this message, and then a final Mapping mediation primitive transforms the values within the Shared context into the aggregated response message. This is illustrated in Figure 1.

Figure 1. Aggregation Fan Out branching

In this case, the Shared context contains the parts of the response messages that need to be stored to generate the aggregated response, as show in Figure 2.

Figure 2. Shared context response messages

This is a simple but powerful usage pattern for aggregation, especially when it is combined into a more complex scenario.

Aggregation patterns