Making asynchronous requests

Using the asynchronous API commands provided with CICS® is a simple way to issue requests to external services and have them run asynchronously. Instead of calling each service sequentially and waiting for a response, the asynchronous API commands provide a simple and powerful way to write asynchronous applications which save wait time and frees up your program to continue with other processing.

How asynchronous processing affects CICS

Using the asynchronous API commands in CICS can enable multiple child transactions to run asynchronously, reducing the overall response time of the application. A parent can run one or more local child transactions that can run asynchronously, and will run in different CICS tasks. It is possible to pass data from a parent to a child and receive back data using CICS channels and containers. The framework of running and fetching child transactions is all done through the use of the supported asynchronous API.

The CICS asynchronous API uses EXEC CICS commands to control the creation, retrieval, and control of child tasks by parent tasks. These commands include:

Comparing sequential transaction processing and asynchronous transaction processing

In a sequential transaction processing scenario, CICS call an external service and waits for a response. CICS may then also call multiple other external services, and wait for responses from them. This sequence can continue until the user receives all the data that is needed. There can be many wait times, and the program execution is blocked until the response is received. Making asynchronous requests illustrates how CICS calls an external service and waits for a response.

Figure 1. Calling services sequentially
The image shows individual parent commands sending single fetches and waiting for returns.

Unlike sequential transaction processing, asynchronous transaction processing provides a way of issuing multiple requests simultaneously. Calling external services asynchronously can reduce the overall response time of the application: the parent is freed up to continue with its own logic separate to its child transactions Figure 2 illustrates that CICS has called several external services at the same time. The wait time is reduced, and the program can continue processing until responses are received.

Figure 2. Calling services in parallel (asychronous processing)
The image shows the parent has issued several children to go out and fetch simultaneously.

Where is asynchronous processing used?

Asynchronous processing is applicable to any situation in which you don't want to halt processing while an external request is being processed.

Related links: