Get method

Retrieves a message from the queue.

This method takes an MQMessage object as a parameter. It uses some of the fields in this object's MQMD as input parameters - in particular the MessageId and CorrelId, so it is important to ensure that these are set as required. See the WebSphere MQ Application Programming Reference for details.

If the method fails then the MQMessage object is unchanged. If it succeeds then the MQMD and Message Data portions of the MQMessage object are completely replaced with the MQMD and Message Data from the incoming message. The MQMessage control properties are set as follows

Defined in:

MQQueue class

Syntax:
Call MQQueue.Get(Message, GetMsgOptions, GetMsgLength)

Parameters

Message:

MQMessage Object representing message to be retrieved.

GetMsgOptions:

Optional MQGetMessageOptions object to control the get operation. If these are not specified, default MQGetMessageOptions are used.

GetMsgLength:

Optional 2- or 4-byte length value to control the maximum length of the WebSphere MQ message that will be retrieved from the queue.

If the MQGMO_ACCEPT_TRUNCATED_MSG option is specified, the GET succeeds with a completion code of MQCC_WARNING and a reason code of MQRC_TRUNCATED_MSG_ACCEPTED if the message size exceeds the specified length.

The MessageData holds the first GetMsgLength bytes of data.

If MQGMO_ACCEPT_TRUNCATED_MSG is not specified, and the message size exceeds the specified length, the completion code of MQCC_FAILED together with reason code MQRC_TRUNCATED_MESSAGE_FAILED is returned.

If the contents of the message buffer are undefined, the total message length is set to the full length of the message that would have been retrieved.

If the message length parameter is not specified, the length of the message buffer is automatically adjusted to at least the size of the incoming message.