Getting messages from a queue

Use this information to learn about getting messages from a queue.

You can get messages from a queue in two ways:
  1. You can remove a message from the queue so that other programs can no longer see it.
  2. You can copy a message, leaving the original message on the queue. This is known as browsing. You can remove the message once you have browsed it.
In both cases, you use the MQGET call, but first your application must be connected to the queue manager, and you must use the MQOPEN call to open the queue (for input, browse, or both). These operations are described in Connecting to and disconnecting from a queue manager and Opening and closing objects.

When you have opened the queue, you can use the MQGET call repeatedly to browse or remove messages on the same queue. Call MQCLOSE when you have finished getting all the messages that you want from the queue.