Determining whether to use data queues or user queues

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 familiar with C or MI programming, you may want to select the user queue. User queues can be accessed only using MI, and MI can be used only by ILE RPG, ILE COBOL, C, and MI programs.

Next, performance plays an important part in determining what type of queue to use. As stated in System APIs or CL commands--when to use each, APIs generally give better performance than CL commands. Also, MI instructions perform better than an external call to an API because APIs have overhead 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 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:

Related concepts
Domain concepts
About application programming interfaces (APIs)