Using Data Queues versus User Queues
Data queues and user queues both provide a means for one or more processes to
communicate asynchronously. The queues can be processed FIFO (first-in
first-out), LIFO (last-in first-out), or by key. If user queues and data queues supply
the same function, which one should you choose for your implementation? The
following is a comparison of the two and an insight into when you should use one
queue rather than the other.
First, your programming experience is an important consideration in selecting a
queue type. If you are skilled in C or MI programming, you may want to select the
user queue. C and MI are the only languages that can use MI instructions, which,
as discussed later, has a bearing on performance. If your expertise is in COBOL or
RPG, then you should choose the data queue. You cannot implement a user
queue in COBOL or RPG because neither of these languages can use MI
instructions.
Next, performance plays an important part in determining what type of queue to
use. As stated in Chapter 1, “Application Programming Interface—Overview” on
page 1-1, APIs generally give better performance than CL commands. Also, MI
instructions perform better than an external call to an API because APIs have over-
head associated with them. User queues use MI instructions to manipulate entries;
data queues use APIs. Therefore, the user queue has better performance than the
data queue.
Last, you need to consider how the queue entries are manipulated. For example,
you need a way to perform enqueue and dequeue operations on entries from a
queue. As stated earlier, user queues use MI instructions to manipulate entries.
Specifically, you use the ENQ MI instruction to enqueue a message, and the DEQ
MI instruction to dequeue a message. If you are running at security level 40 or
greater, you must ensure that the user queue is created in the user domain in order
to directly manipulate a user queue using MI instructions. Because data queue
entries are manipulated by APIs, the security level of the machine does not limit the
use of the API.
You cannot create a user queue object in a library that does not permit user-
domain objects, which is determined by the QALWUSRDMN system value. (See
“Domain Concepts” on page 2-26 for more information on QALWUSRDMN.) Data
queues are always created in the system domain, so there is no problem with the
data queue being created into a specific library.
The following is a summary to help you select the type of queue that is right for
your program:
Use user queues when:
– You have a programming background in or prefer to program in C or MI.
– You need the additional performance of an API for creating and deleting
and MI instructions for manipulating entries.
– You do not need to create a user-domain queue into a library where the
QALWUSRDMN system value does not permit user-domain user objects
when at security level 40 or 50.
Use data queues when:
– You have a programming background in or prefer to program in COBOL or
RPG.
Appendix A. Performing Tasks Using APIs—Examples A-15