Queues

Queues are sequential storage facilities, generally transitory in nature because of the dynamic nature of transaction processing. Typically, they are used to process requests or to pass data from one transaction to another as shown in Figure 1. For example, data that is produced as part of a transaction is usually not printed until long after its task has been completed; the data waits in a queue for the print program to process it when no more urgent work is to be done.
Figure 1. General use of queues
General use of queues

A queue is a sequence of data elements that is identified by a symbolic name. Each element contains record-oriented data of a type specific to the application that is to process it. Elements of different types can be put into the same queue.

For the general type of queue, transactions add (enqueue) elements to the tail of the queue and remove (dequeue) elements from the head of the queue in a first-in first-out (FIFO) way. Each element must be read sequentially and, when read, removed from the queue. Queues support multiple simultaneous requests to enqueue and dequeue elements, growing and shrinking in size in response to the volume of requests. A transaction can requeue elements to another queue for alternative processing.

You can use some queues differently; for example, as a common scratchpad of elements that are to be written, updated, read, and deleted by any transactions. You can also dequeue elements in a different sequence from the sequence in which they were enqueued.

Before a queue can be used, you must define it. For example, a queue definition is used by CICS® to identify the symbolic name and type of a queue, and to define the queue to the appropriate queue manager.

Figure 2 shows queues being used to support a telephone sales business application. Each sales agent runs an application (on transaction server A) and confirms sales to customers in real time to preserve critical response times. Each transaction adds the data that is associated with the sale orders to queues for later processing. The larger task of processing the order is split into billing, shipping, and updating inventory applications. These applications run separately from the initial order-taking application, as transactions on transaction server B. These transactions dequeue the data that they are to process.
Figure 2. An example use of queues
An example use of queues
CICS supports the following types of queues:

Transient data queues provide the general queue functions. Temporary storage queues are typically used for shared reading, writing, and updating by multiple transactions; for example, as a scratchpad for shared data.

Some of the main differences between the types of queue are as follows:
  • Transient data queues must be defined to a CICS region before it starts up. In contrast, temporary storage queues can be created any time that an application needs to write to a queue.
  • Transient data queues must be read sequentially, and each element can be read only once. (After a transaction reads an element, that element is removed from the queue and is not available to any other transaction.) In contrast, elements that are in temporary storage queues can be read either sequentially or directly. They can be read any number of times and are never removed from the queue until the whole queue is purged.

These two characteristics make transient data queues inappropriate for scratchpad data but suitable for queued data such as audit trails and output that is to be printed. For data that is read sequentially once, transient data queueing is preferable to temporary storage.