Allocating data queues

If all users of a data queue allocate it before using it, this helps to ensure that a data queue is not accessed by more than one job at a time.

If your application requires that a data queue is not accessed by more than one job at a time, it should be coded to include an Allocate Object (ALCOBJ) command before using a data queue. The data queue should then be deallocated using the Deallocate Object (DLCOBJ) command when the application is finished using it.

The ALCOBJ command does not, by itself, restrict another job from sending or receiving data from a data queue or clearing a data queue. However, if all applications are coded to include the ALCOBJ command before any use of a data queue, the allocation of a data queue already allocated to another job will fail, preventing the data queue from use by more than one job at a time.

When an allocation fails because the data queue is already allocated to another job, the system issues error message CPF1002. The Monitor Message (MONMSG) command can be used in the application program or procedure to monitor for this message and to respond to the error message. Possible responses include sending a message to the user and attempting to allocate the data queue again.

A data queue can be changed to indicate that IBM-supplied operations enforce a lock on a data queue. Before V6R1, locks placed on a data queue by the ALCOBJ function are ignored by IBM-supplied operations. Performance of the data queue can be impacted with the use of this attribute to enforce data queue locks. See the Change Data Queue (QMHQCDQ) API for information about how to change a data queue to enforce data queue locks and to obtain details on the locks to be used for the various data queue operations.