The WebSphere® ESB aggregation
sample demonstrates the use of iteration to achieve aggregation of
data.
About this task
The iteration aggregation sample is based on a user submitting
a batch of orders within a single request. Each order contains a customer
identifier, an item identifier and a quantity. Time can be saved by
submitting multiple orders in a single batch, identified by an identifier.
The system will handle the batch and return the status information
back to the user.
Before the batch can be submitted to the
dispatch backend service, each order in the batch must be enriched
with customer mailing information from a customer service. What is
not shown below is that the response flow, which simply translates
the status information returned by the dispatch system to the store
response format.
Procedure
- Store the batch identifier.
- For each order, build a message to send to the Customer
service. If there are no orders in the batch, to save unnecessary
calls to the dispatch backend service, build and return an empty response.
- Call the Customer service to retrieve mailing information
for the customer. If there are any errors, stop processing.
- Store the result in the shared aggregation context.
- Add the result to the list of orders already enriched.
- Return to step 2 to process the next order.
- When all orders are completed, build the message to send
to the dispatch system, including the newly enriched order batch.
- Send the new message to the dispatch system.
Results
In the iteration aggregation sample, the customer and dispatch
services are implemented as Java™ objects exposed as SOAP/HTTP web services, while
the mediation itself is exposed as a SOAP/HTTP web service. Shared
interfaces and business objects are held in a separate library called
StoreLib. The whole system can be tested by using the included StoreClient
web application which allows a user to build a batch, submit it to
the mediation, and view the returned results.