[AIX, Linux, Windows]

The Browser sample program

The Browser sample program reads and writes both the message descriptor and the message content fields of all the messages on a queue.

The sample program is written as a utility, not just to demonstrate a technique. See Features demonstrated in the sample programs on Multiplatforms for the names of these programs.

This program takes these positional parameters:
  1. The name of the source queue (required)
  2. The name of the queue manager (required)
  3. An optional parameter for properties (optional)
Use the following environment variables to supply credentials that are used to authenticate with the queue manager:
MQSAMP_USER_ID
Set to the user ID to be used for connection authentication, if you want use a user ID and a password to authenticate with the queue manager. The program prompts for the password to accompany the user ID.
[AIX][MQ 9.3.4 Oct 2023][Linux]MQSAMP_TOKEN
Set to a non-blank value if you want to supply an authentication token to authenticate with the queue manager. The program prompts for the authentication token. Authentication tokens can be used only by the amqsbcgc sample that uses client bindings.
To run these programs, enter one of the following commands:
  • amqsbcg myqueue qmanagername
  • amqsbcgc myqueue qmanagername
where myqueue is the name of the queue on which the messages are going to be browsed, and qmanagername is the queue manager that owns myqueue.
It reads each message from the queue and writes the following to stdout:
  • Formatted message descriptor fields
  • Message data (dumped in hex and, where possible, character format)
Table 1. Permissible values for the property parameter
Value Behavior
0 Default behavior. The properties that get delivered to the application depend on the PropertyControl queue attribute that the message is retrieved from.
1 A message handle is created and used with the MQGET. Properties of the message, except those contained in the message descriptor (or extension) are displayed in a similar fashion to the message descriptor. For example:

****Message properties****
   property name: property value   
Or if no properties are available:

****Message properties****
   None
Numeric values are displayed using printf, string values are surrounding in single quotation marks, and byte strings are surrounded with X and single quotation marks, as for the message descriptor.
2 MQGMO_NO_PROPERTIES is specified, so that only message descriptor properties will be returned.
3 MQGMO_PROPERTIES_FORCE_MQRFH2 is specified, so that all properties are returned in the message data.
4 MQGMO_PROPERTIES_COMPATIBILITY is specified, so that all properties can be returned depending on whether an IBM MQ property is included, otherwise the properties are discarded.

The program is restricted to printing the first 65535 characters of the message, and fails with the reason truncated msg if a longer message is read.

For an example of the output from this utility, see Browsing queues.