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)

These programs also use an environment variable named MQSAMP_USER_ID which should be set to the user ID to be used for connection authentication. When this is set, the program prompts for a password to accompany that user ID.

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)

Value Behavior
0 Default behavior, as it was for Version 6. 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 a Version 6 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.

Parent topic: Use the sample programs on Multiplatforms