Considerations for using data queues and user queues
To decide whether to use data queues or user queues, you need to consider your programming experience, the performance of each queue type, and the operations on queue entries.
First, your programming experience is an important consideration in selecting a queue type. If you are familiar with C or MI programming, you might want to select the user queue. User queues can be accessed only through 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. 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 summary can help you select the type of queue that is right for your program:
- Use user queues when:
- You have a programming background in 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 a high-level language such as COBOL, C, or RPG.
- You do not need the additional performance of MI instructions for directly manipulating entries.
- You need to create queues into a library that is not listed in the QALWUSRDMN system value.