Methods

Close

public override void Close()

Overrides MQManagedObject.Close.

Get

public void Get(MQMessage message,
                MQGetMessageOptions getMessageOptions,
                int MaxMsgSize)

Throws MQException.

Retrieves a message from the queue, up to a maximum specified message size.

This method takes an MQMessage object as a parameter. It uses some of the fields in the object as input parameters, in particular the messageId and correlationId, so it is important to ensure that these are set as required.

If the get fails, the MQMessage object is unchanged. If it succeeds, the message descriptor (member variables) and message data portions of the MQMessage are completely replaced with the message descriptor and message data from the incoming message.

All calls to WebSphere MQ from a given MQQueueManager are synchronous. Therefore, if you perform a get with wait, all other threads using the same MQQueueManager are blocked from making further WebSphere MQ calls until the get completes. If we need multiple threads to access WebSphere MQ simultaneously, each thread must create its own MQQueueManager object.

Parameters

message

An input/output parameter containing the message descriptor information and the returned message data.

getMessageOptions

Options controlling the action of the get. (See MQGetMessageOptions.)

Using option MQC.MQGMO_CONVERT might result in an exception with reason code MQException.MQRC_CONVERTED_STRING_TOO_BIG when converting from single byte character codes to double byte codes. In this case, the message is copied into the buffer but remains encoded using its original character set.

MaxMsgSize

The largest message this call can receive. If the message on the queue is larger than this size, one of two things occurs:

  1. If the MQC.MQGMO_ACCEPT_TRUNCATED_MSG flag is set in the options member variable of the MQGetMessageOptions object, the message is filled with as much of the message data as will fit in the specified buffer size, and an exception is thrown with completion code MQException.MQCC_WARNING and reason code MQException.MQRC_TRUNCATED_MSG_ACCEPTED.

  2. If the MQC.MQGMO_ACCEPT_TRUNCATED_MSG flag is not set, the message is left on the queue and an MQException is raised with completion code MQException.MQCC_WARNING and reason code MQException.MQRC_TRUNCATED_MSG_FAILED.

Throws MQException if the get fails.

Get

public void Get(MQMessage message,
                MQGetMessageOptions getMessageOptions)

Throws MQException.

Retrieves a message from the queue, regardless of the size of the message. For large messages, the get method might have to issue two calls to WebSphere MQ on your behalf, one to establish the required buffer size and one to get the message data itself.

This method takes an MQMessage object as a parameter. It uses some of the fields in the object as input parameters, in particular the messageId and correlationId, so it is important to ensure that these are set as required.

If the get fails, the MQMessage object is unchanged. If it succeeds, the message descriptor (member variables) and message data portions of the MQMessage are completely replaced with the message descriptor and message data from the incoming message.

All calls to WebSphere MQ from a given MQQueueManager are synchronous. Therefore, if you perform a get with wait, all other threads using the same MQQueueManager are blocked from making further WebSphere MQ calls until the get completes. If we need multiple threads to access WebSphere MQ simultaneously, each thread must create its own MQQueueManager object.

Parameters

message

An input/output parameter containing the message descriptor information and the returned message data.

getMessageOptions

Options controlling the action of the get. (See MQGetMessageOptions for details.)

Throws MQException if the get fails.

Get

public void Get(MQMessage message)

A simplified version of the Get method previously described.

Parameters

MQMessage

An input/output parameter containing the message descriptor information and the returned message data.

This method uses a default instance of MQGetMessageOptions to do the get. The message option used is MQGMO_NOWAIT.

Put

public void Put(MQMessage message,
                MQPutMessageOptions putMessageOptions)

Throws MQException.

Places a message onto the queue.

Note:
For simplicity and performance, if you want to put just a single message to a queue, use the Put() method on the MQQueueManager object. For this you do not need to have an MQQueue object. See MQQueueManager.Put.

This method takes an MQMessage object as a parameter. The message descriptor properties of this object can be altered as a result of this method. The values that they have immediately after the completion of this method are the values that were put onto the WebSphere MQ queue.

Modifications to the MQMessage object after the put has completed do not affect the actual message on the WebSphere MQ queue.

A Put updates the messageId and correlationId. Consider this when making further calls to Put/Get using the same MQMessage object. Also, calling Put does not clear the message data, so:

msg.WriteString("a");
q.Put(msg,pmo);
msg.WriteString("b");
q.Put(msg,pmo);

puts two messages. The first contains

a and the second

ab.

Parameters

message

Message Buffer containing the Message Descriptor data and message to be sent.

putMessageOptions

Options controlling the action of the put. (See MQPutMessageOptions)

Throws MQException if the put fails.

Put

public void Put(MQMessage message)

A simplified version of the Put method previously described.

Parameters

MQMessage

Message Buffer containing the Message Descriptor data and message to be sent.

This method uses a default instance of MQPutMessageOptions to do the put.


csqzav0565