Previous Topic: MQ OPEN—Open a Queue

Next Topic: MQ PUT—Put Messages on the Queue

MQ GET—Retrieve Messages

The ADDRESS MQ GET command retrieves messages from the message queue using the FIFO retrieval method.

This command has the following format:

ADDRESS MQ GET OPTIONS([TRUNCATE] [KEEP] [CORRELID(corr)] [WAIT(time])
   {CONHANDLE(varHCONN)}
   {OBJHANDLE(varHOBJ)}
   {DATA(varDATA)}
OPTIONS

Specifies the processing options.

TRUNCATE

(Optional) Allows data to be truncated. If omitted, the GET operation will fail when the data contains over 32,000 bytes.

KEEP

(Optional) Causes messages to be kept on the queue. Keep is required when the queue is being browsed.

CORRELID

(Optional) Defines the correlation ID of the message to be returned.

Note: The CORRELID must be specified in hex format.

WAIT

(Optional) Specifies the amount of time in seconds to wait for the message. If omitted, GET does not wait for any messages.

Possible value: 1 to 900 seconds

CONHANDLE(varHCONN)

Defines the variable name that stores the connection handle.

OBJHANDLE(varHOBJ)

Defines the variable name that stores the object handle.

DATA(varDATA)

Defines the variable name that stores the message.

Example: MQ GET

This example gets a message with a specific CorrelID, stored in variable mycorr:

ADDRESS MQ "GET OPTIONS(CORRELID("mycorr"))",
           "CONHANDLE(hconn) OBJHANDLE(hobj) DATA(data2get)"