IBM Support

How to extract a single message from an IBM MQ queue

Technote (FAQ)


How do you subscribe to a single message on a queue without removing others using IBM Rational Integration Tester (RIT) of IBM Rational Test Workbench (RTW)?


You need to extract a single message from an IBM WebSphere MQ queue, based on its message content. You must not remove any other messages from the queue as they are used by other consumers or applications.


This solution uses IBM WebSphere MQ as the messaging system and contains an attachment of a sample project to demonstrate it.

Usually you take a specific message from a queue by using a combination of the queue name and a unique identifier. An example is: Message ID or Correlation ID. The assumption is that you do not know the message identifiers, but you do know what the message payload will contain.

The following are high-level steps, the example project has a working test with comments.

  1. Create a physical IBM WebSphere MQ transport in Architecture School.

  2. Create a logical IBM WebSphere MQ transport and bind it to the physical transport.

  3. Create a new test in Test Factory.

  4. Add an Iterate While loop to go through the complete queue of messages.

  5. Add a Subscribe action inside the loop and set the queue name and configure it for Watch mode.

  6. Tag the Message ID.

  7. Test the content of the message.

  8. Exit the Iterate While loop if the content is what is required; you have located the correct message.

  9. Use a Subscribe action with the Message ID in the Message Selector configuration to match the required message and remove it from the queue.
    Select Participate mode.

  • You cannot solve this problem using the RIT Subscribe action with the Filter settings. This method will find the right message but it will permanently remove all previous messages from the queue as it discards those that do not match the filter.

  • The solution offered here might work with some other messaging systems if those systems support queue browsing and the use of message selectors.

  • See the RTW Information Center for full details of creating and running tests, and for configuring connections to IBM MQ systems.


All source code and/or binaries attached to this document are referred to here as "the Program". IBM is not providing program services of any kind for the Program. IBM is providing the Program on an "AS IS" basis without warranty of any kind. IBM WILL NOT BE LIABLE FOR ANY ACTUAL, DIRECT, SPECIAL, INCIDENTAL, OR INDIRECT DAMAGES OR FOR ANY ECONOMIC CONSEQUENTIAL DAMAGES (INCLUDING LOST PROFITS OR SAVINGS), EVEN IF IBM, OR ITS RESELLER, HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

RIT One MQ Message.zipRIT One MQ

Document information

More support for: Rational Test Workbench
Rational Integration Tester

Software version: 8.0, 8.5

Operating system(s): AIX, Linux, OS X, Solaris, Windows

Reference #: 1624757

Modified date: 07 April 2014