Passing data between jobs using queues is a powerful technique on IBM i. Both data queues and user queues can handle thousands of messages with minimal overhead—making them a go-to tool for efficient inter-job communication.
But if you’ve assumed FIFO (First In, First Out) always guarantees correct message order, you may want to read on.
Data queues use APIs, which include parameter validation and other overhead. That makes them roughly three times slower than user queues, which access the queue directly via MI instructions through the C function library. If performance matters, user queues are the better choice.
At iPerformance ApS, we’ve relied on user queues for over a decade in GiAPA, our performance analysis tool. They help us pass job identifiers and other metadata efficiently—even on systems with thousands of active jobs.
In 2015, some of our customers began reporting sporadic issues: messages sent to user queues appeared to arrive out of order. This led to strange and hard-to-reproduce failures, where job data couldn’t be matched to the correct job identifier.
After lengthy debugging, we discovered that two messages written in the correct order were, in rare cases, retrieved in the opposite sequence. This only happened on newer, faster servers. Our conclusion? The system was getting so fast that multiple enqueue operations completed within the same microsecond—resulting in identical timestamps.
When the system then sorted messages by timestamp (as part of the dequeue operation), it couldn’t always preserve the intended order. That’s not a bug—it’s a limitation of relying on timestamps with insufficient precision.
To fix this, we added a 1-microsecond delay before enqueueing the second of two related messages. That tiny change resolved the issue completely—and taught us a valuable lesson.
For developers working in RPGLE, we’ve made our user queue source code available on giapa.com/downloads to help you implement and test similar queue logic in your own applications.
In this section, you'll find in-depth articles, practical tips, and real-world experiences aimed at helping system administrators and IT decision-makers improve performance, reduce resource usage, and get more value from their IBM i environments. Whether you're exploring general best practices or diving into specific GiAPA capabilities, our insights are here to guide you. Explore, learn, and optimize.
In this section, you'll find in-depth articles, practical tips, and real-world experiences aimed at helping system administrators and IT decision-makers improve performance, reduce resource usage, and get more value from their IBM i environments. Whether you're exploring general best practices or diving into specific GiAPA capabilities, our insights are here to guide you. Explore, learn, and optimize.