MQQueue

public class MQQueue
extends MQManagedObject
java.lang.Object
   |
   +----com.ibm.mq.MQManagedObject
           |
           +----com.ibm.mq.MQQueue
          

MQQueue provides inquire, set, put and get operations for WebSphere MQ queues. The inquire and set capabilities are inherited from MQManagedObject.

Use MQQueueManager.accessQueue() to gain access to an MQQueue object.

Constructors

MQQueue

public MQQueue(MQQueueManager qMgr, String queueName, int openOptions, 
               String queueManagerName, 
               String dynamicQueueName, String alternateUserId) 
              throws MQException;

Public constructor which allows users to create MQQueue subclasses.

Parameters
Exceptions

Methods

close

public void close() throws MQException;

Closes the object. No further operations on this object are permitted after it is closed. The behavior of the close method can be altered by setting closeOptions.

Exceptions

get

public void get(MQMessage message) throws MQException;

Retrieves a message from the queue, using default get message options. It uses an option setting of MQC.MQGMO_NO_WAIT.

Parameters
Exceptions

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, this might require two calls to WebSphere MQ, One to establish the required buffer size and one to get the message data itself.

If the call fails, the MQMessage object is unchanged. If it succeeds, the message descriptor fields and message data portions of the MQMessage are completely overwritten by the fields and data from the incoming message.

Note that if you perform a get with wait, all other threads using the same MQQueueManager are blocked until the call completes. If you need multiple threads to access WebSphere MQ simultaneously, then each thread must create its own MQQueueManager object.

Parameters
Exceptions

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.

If the call fails, the MQMessage object is unchanged. If it succeeds, the message descriptor fields and message data portions of the MQMessage are completely overwritten by the fields and data from the incoming message.

If you perform a get with wait, all other threads using the same MQQueueManager are blocked until the call completes. If you need multiple threads to access WebSphere MQ simultaneously, then each thread must create its own MQQueueManager object.

Parameters
Exceptions

getCreationDateTime

public GregorianCalendar getCreationDateTime() throws MQException;

Gets the date and time that this queue was created.

Returns
Exceptions

getCurrentDepth

public int getCurrentDepth() throws MQException;

Gets the number of messages currently on the queue. This value is incremented during a put call and during backout of a get call. It is decremented during a non-browse get and during backout of a put call.

Returns
Exceptions

getDefinitionType

public int getDefinitionType() throws MQException;

Indicates how the queue was defined.

Returns
Exceptions

getInhibitGet

public int getInhibitGet() throws MQException;

Indicates whether get operations are allowed for this queue.

Returns
Exceptions

getInhibitPut

public int getInhibitPut() throws MQException;

Indicates whether put operations are allowed for this queue.

Returns
Exceptions

getMaximumDepth

public int getMaximumDepth() throws MQException;

Gets the maximum number of messages that can exist on the queue at any one time. An attempt to put a message to a queue that already contains this many messages fails with reason code MQException.MQRC_Q_FULL .

Returns
Exceptions

getMaximumMessageLength

public int getMaximumMessageLength() throws MQException;

Gets the maximum length of the application data of a message on this queue. An attempt to put a message larger than this value fails with reason code MQException.MQRC_MSG_TOO_BIG_FOR_Q.

Returns
Exceptions

getOpenInputCount

public int getOpenInputCount() throws MQException;

Gets the number of currently valid handles for removing messages from the queue.

Returns
Exceptions

getOpenOutputCount

public int getOpenOutputCount() throws MQException;

Gets the number of currently valid handles for adding messages to the queue.

Returns
Exceptions

getQueueType

public int getQueueType() throws MQException;

Gets the type of this queue.

Returns
Exceptions

getShareability

public int getShareability() throws MQException;

Indicates whether the queue can be opened multiple times for input.

Returns
Exceptions

getTriggerControl

public int getTriggerControl() throws MQException;

Indicates whether trigger messages are written to an initiation queue. This starts an application to service the queue.

Returns
Exceptions

getTriggerData

public String getTriggerData() throws MQException;

Gets the data for the trigger message that is written to the initiation queue. The trigger message is written to the initiation queue when a message arrives on this one.

Returns
Exceptions

getTriggerDepth

public int getTriggerDepth() throws MQException;

Gets the number of messages that have to be on the queue to generate a trigger message. This applies when the trigger type is MQC.MQTT_DEPTH.

Returns
Exceptions

getTriggerMessagePriority

public int getTriggerMessagePriority() throws MQException;

Gets the message priority below which messages do not cause trigger messages. That is, the queue manager ignores these messages when deciding whether to generate a trigger.

Returns
Exceptions

getTriggerType

public int getTriggerType() throws MQException;

Indicates the conditions under which trigger messages are written. Trigger messages are written as a result of messages arriving on this queue.

Returns
Exceptions

put

public void put(MQMessage message) throws MQException;

Puts a message onto the queue using default put message options.

Parameters
Exceptions

put

public void put(MQMessage message, MQPutMessageOptions putMessageOptions) 
              throws MQException;

Puts a message onto the queue.

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

If you use the same MQMessage object to make further calls, then performing a put updates MQMessage.messageId and MQMessage.correlationId.

Note also that calling put does not clear the message data. For example:

 msg.writeString("a");
 q.put(msg,pmo);
 msg.writeString("b");
 q.put(msg,pmo); 
 

results in "ab" being put by the second call.

Parameters
Exceptions

setInhibitGet

public void setInhibitGet(int inhibit) throws MQException;

Controls whether get operations are allowed for this queue.

Parameters
Exceptions

setInhibitPut

public void setInhibitPut(int inhibit) throws MQException;

Controls whether put operations are allowed for this queue.

Parameters
Exceptions

setTriggerControl

public void setTriggerControl(int trigger) throws MQException;

Controls whether trigger messages are written to an initiation queue. This starts an application to service the queue.

Parameters
Exceptions

setTriggerData

public void setTriggerData(String data) throws MQException;

Sets the data for the trigger message that is written to the initiation queue. The trigger message is written to the initiation queue when a message arrives on this one.

Parameters
Exceptions

setTriggerDepth

public void setTriggerDepth(int depth) throws MQException;

Sets the number of messages that have to be on the queue to generate a trigger message. This applies when trigger type is MQC.MQTT_DEPTH .

Parameters
Exceptions

setTriggerMessagePriority

public void setTriggerMessagePriority(int priority) throws MQException;

Sets the message priority below which messages do not cause trigger messages. That is, the queue manager ignores these messages when deciding whether to generate a trigger.

Parameters
Exceptions

setTriggerType

public void setTriggerType(int type) throws MQException;

Sets the conditions under which trigger messages are written. Trigger messages are written as a result of messages arriving on this queue.

Parameters
Exceptions