Websphere MQ Everyplace

com.ibm.mqe
Class MQeEnumeration

java.lang.Object
  |
  +--com.ibm.mqe.MQe
        |
        +--com.ibm.mqe.MQeEnumeration
All Implemented Interfaces:
java.util.Enumeration, MQeExceptionCodes

public class MQeEnumeration
extends MQe
implements java.util.Enumeration

This class is used to hold a collection of WebSphere MQ Everyplace message objects. It allows the messages to be enumerated in an identical manner to the standard Java Enumeration class.

Implements java.util.Enumeration.


Field Summary
 
Fields inherited from class com.ibm.mqe.MQe
Admin_Queue_Name, Admin_Reply_Queue_Name, copyright, DeadLetter_Queue_Name, Event_Activate, Event_Attribute, Event_Authenticate, Event_Close, Event_Logoff, Event_Logon, Event_MiniCert_Validate, Event_Queue, Event_QueueManager, Event_UserBase, JMS_Version, MQ_Headers, MQe_Log_Audit_Failure, MQe_Log_Audit_Success, MQe_Log_Error, MQe_Log_Information, MQe_Log_Success, MQe_Log_Warning, Msg_BackoutCount, Msg_CorrelID, Msg_ExpireTime, Msg_LockID, Msg_MsgID, Msg_OriginQMgr, Msg_Priority, Msg_ReplyToQ, Msg_ReplyToQMgr, Msg_Resend, Msg_Style, Msg_Style_Datagram, Msg_Style_Reply, Msg_Style_Request, Msg_Time, Msg_WrapMsg, sccsid, System_Default_Queue_Name, version
 
Fields inherited from interface com.ibm.mqe.MQeExceptionCodes
Except_Active, Except_AdapterException, Except_AdapterMissingRemoteAddress, Except_Admin_ActionNotSupported, Except_Admin_InvalidField, Except_Admin_NotAdminMsg, Except_AdminAction, Except_Authenticate, Except_BadRequest, Except_BridgeListener, Except_Chnl_Attributes, Except_Chnl_ID, Except_Chnl_Limit, Except_Chnl_Overrun, Except_Closed, Except_Con_AdapterRequired, Except_Con_AliasAlreadyExists, Except_Con_AlreadyExists, Except_Con_InvalidName, Except_Connect_Failure, Except_ConnectonType, Except_Cryptor, Except_Data, Except_Duplicate, Except_JmxProperties, Except_Listener, Except_MessageStore, Except_MiniCertReg_ActivateFailed, Except_MiniCertReg_BadPIN, Except_MiniCertReg_NotOpen, Except_NotActive, Except_NotAllowed, Except_NotFound, Except_NotSupported, Except_PrivateReg_ActivateFailed, Except_PrivateReg_BadPIN, Except_PrivateReg_NotOpen, Except_PublicReg_ActivateFailed, Except_PublicReg_InvalidAddress, Except_PublicReg_InvalidRequest, Except_Q_Full, Except_Q_InvalidName, Except_Q_InvalidPriority, Except_Q_MsgTooLarge, Except_Q_NoMatchingMsg, Except_Q_TargetRegistryRequired, Except_QMgr_Activated, Except_QMgr_AlreadyExists, Except_QMgr_InvalidQMgrName, Except_QMgr_InvalidQName, Except_QMgr_NotActive, Except_QMgr_NotBridgeEnabled, Except_QMgr_NotConfigured, Except_QMgr_QDoesNotExist, Except_QMgr_QExists, Except_QMgr_QNotEmpty, Except_QMgr_RegistryDataVersion, Except_QMgr_UnknownQMgr, Except_QMgr_WrongQType, Except_Reg_AddFailed, Except_Reg_AlreadyExists, Except_Reg_AlreadyOpen, Except_Reg_CRTKeyDecFailed, Except_Reg_CRTKeySignFailed, Except_Reg_DeleteFailed, Except_Reg_DeleteRegistryFailed, Except_Reg_DoesNotExist, Except_Reg_InvalidSession, Except_Reg_ListFailed, Except_Reg_NotDefined, Except_Reg_NotSecure, Except_Reg_NullName, Except_Reg_OpenFailed, Except_Reg_ReadFailed, Except_Reg_RenameFailed, Except_Reg_ResetPINFailed, Except_Reg_SearchFailed, Except_Reg_UpdateFailed, Except_RemoteException, Except_Rule, Except_S_BadIntegrity, Except_S_BadSubject, Except_S_CertificateExpired, Except_S_Cipher, Except_S_InvalidAttribute, Except_S_InvalidSignature, Except_S_MiniCertNotAvailable, Except_S_MissingSection, Except_S_NoPresetKeyAvailable, Except_S_RegistryNotAvailable, Except_Stopped, Except_Syntax, Except_TimeOut, Except_Transporter, Except_TriggerTransmission, Except_Trnsport_QMgr, Except_Trnsport_Request, Except_Type, Except_UdpipAdapterStateException, Except_UdpipAdapterTimeOut, Except_UdpipAdapterUnableToConfirmSuccess, Except_UnCoded, Except_Uncontactable_DontTransmit
 
Constructor Summary
MQeEnumeration(java.util.Enumeration enumeration)
          Simple constructor.
MQeEnumeration(java.util.Enumeration enumeration, long lockID, java.lang.String queueManager, java.lang.String queue)
          Constrctor to enumerate messages of the given QueueManager, Queue and the LockId of the browseWithLock.
 
Method Summary
 long getLockId()
          Returns the lockID associated with this group of messages, if one exists.
 MQeMsgObject getNextMessage(MQeAttribute attribute, long confirmID)
          Deprecated. This method has been deprecated because of the ambiguity in its use. The functionality that this method provides is available through other API calls. The calls used will depend upon whether the enumeration was generated for justUIDs and whether a destructive read (message is removed from queue) or non destuctive read (message remains on queue) is required. - If the enumeration was generated as a result of a browse with the justUID flag set to false, then the nextElement method returns a copy of the message (non destructive read). If a destructive read is required, the message can be used as a filter to perform a getMessage or deleteMessage call. - If the enumeration was generated as a result of a browse with the justUID flag set to true, then the nextElement method returns an MQeFields instance which can be used to perform a destuructive getMessage or a non-destructive browseMessages.
 java.lang.String getQueueManagerName()
          Returns the name of the queue manager that owns the queue from which the messages contained in the enumeration were browsed.
 java.lang.String getQueueName()
          Returns the name of the queue from which the messages contained in the enumeration were browsed.
 
Methods inherited from class com.ibm.mqe.MQe
abbreviate, alias, asciiToByte, byteToAscii, byteToHex, byteToHex, byteToInt, byteToLong, byteToShort, byteToUnicode, fileSeparator, getEventLogHandler, hexToAscii, hexToByte, intToByte, isCLDC, loadClass, loadObject, log, setEventLogHandler, setLoader, sliceByteArray, type, unicodeToByte, uniqueValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Enumeration
hasMoreElements, nextElement
 

Constructor Detail

MQeEnumeration

public MQeEnumeration(java.util.Enumeration enumeration)

Simple constructor.


MQeEnumeration

public MQeEnumeration(java.util.Enumeration enumeration,
                      long lockID,
                      java.lang.String queueManager,
                      java.lang.String queue)

Constrctor to enumerate messages of the given QueueManager, Queue and the LockId of the browseWithLock.

Parameters:
enumeration - The enumeration of messages of message UID's
lockID - The lock ID of a browseWithLock was used
queueManager - The name of the target queue manager
queue - The name of the target queue
Method Detail

getLockId

public long getLockId()

Returns the lockID associated with this group of messages, if one exists.

If a there is a lockID associated with the group of messages contained in this enumeration, it is returned by this method. The lockID is only set if this enumeration is the result of a browseMessagesAndLock operation.

Otherwise this method returns a dummy value of "-1".

Returns:
A long value containing the lockID of the group of messages contained within this enumeration.
Example:
 // Lock all msgs on this queue
 long lockId = 0;
 MQeEnumeration msgEnum = null;
 
 try {
     MQeQueueManager QMgr = new MQeQueueManager();
 
     msgEnum = QMgr.browseMessagesAndLock(null,
                 "MyQueue",
                 null, null, 0, false);
 } catch (Exception e) {
     System.err.println("Failure ! " + e.toString());
 }
 lockId = msgEnum.getLockId(); // get the Lock Id
 return lockId;
 
 

getQueueManagerName

public java.lang.String getQueueManagerName()

Returns the name of the queue manager that owns the queue from which the messages contained in the enumeration were browsed.

Returns:
A String containing the name of the queue manager that owns the queue from which these messages were browsed.
See Also:
getQueueName()
Example:
 MQeEnumeration msgEnum = null;
 MQeMsgObject msg = null;
 String QMgrName = " ";
 
 try {
     MQeQueueManager QMgr = new MQeQueueManager();
 
     msgEnum = QMgr.browseMessages("RemoteQMgr", "RemoteQueue", null, null, false);
     while (msgEnum.hasMoreElements()) {
         // get message
         msg = (MQeMsgObject) msgEnum.nextElement();
         //msg =msgEnum.getNextMessage(null,MQe.uniqueValue());
         // confirm get
         QMgr.confirmGetMessage(msgEnum.getQueueManagerName(),
             msgEnum.getQueueName(),
             msg.getMsgUIDFields());
         QMgrName = msgEnum.getQueueManagerName();
     }
 } catch (Exception e) {
     System.err.println("Failure ! " + e.toString());
 }
 return QMgrName;
 
 

getQueueName

public java.lang.String getQueueName()

Returns the name of the queue from which the messages contained in the enumeration were browsed.

Returns:
A String containing the name of the queue from which these messages were browsed.
See Also:
getQueueManagerName()
Example:
 MQeEnumeration msgEnum = null;
 MQeMsgObject msg = null;
 String QName = " ";
 
 try {
     MQeQueueManager QMgr = new MQeQueueManager();
 
     msgEnum = QMgr.browseMessages("RemoteQMgr", "RemoteQueue", null, null, false);
     while (msgEnum.hasMoreElements()) {
         // get message
         msg = (MQeMsgObject) msgEnum.nextElement();
         //msg =msgEnum.getNextMessage(null,MQe.uniqueValue());
         // confirm get
         QMgr.confirmGetMessage(msgEnum.getQueueManagerName(),
             msgEnum.getQueueName(),
             msg.getMsgUIDFields());
         QName = msgEnum.getQueueName();
     }
 } catch (Exception e) {
     System.err.println("Failure ! " + e.toString());
 }
 return QName;
 
 

getNextMessage

public MQeMsgObject getNextMessage(MQeAttribute attribute,
                                   long confirmID)
                            throws java.lang.Exception
Deprecated. This method has been deprecated because of the ambiguity in its use. The functionality that this method provides is available through other API calls. The calls used will depend upon whether the enumeration was generated for justUIDs and whether a destructive read (message is removed from queue) or non destuctive read (message remains on queue) is required. - If the enumeration was generated as a result of a browse with the justUID flag set to false, then the nextElement method returns a copy of the message (non destructive read). If a destructive read is required, the message can be used as a filter to perform a getMessage or deleteMessage call. - If the enumeration was generated as a result of a browse with the justUID flag set to true, then the nextElement method returns an MQeFields instance which can be used to perform a destuructive getMessage or a non-destructive browseMessages.

Returns the next message in the enumeration.

Parameters:
attribute - An MQeAttribute object used to decode the message if it was encoded.
confirmID - A confirmId to use if the getMessage is to be issued specifying a confirmID.
Returns:
An MQeMsgObject containing the next element in the enumeration.

Note:This method will issue a getMessage to the target system i.e. retrieve the the message if this enumeration was the result of browse that requested just UID's. In other words the behaviour is defferent depending on how the browse request was issued.

Throws:
MQeException - Except_NotSupported
java.lang.Exception
Example:
 MQeEnumeration msgEnum = null;
 MQeMsgObject msg = null;
 
 try {
     MQeQueueManager QMgr = new MQeQueueManager();
 
     msgEnum = QMgr.browseMessages("RemoteQMgr", "RemoteQueue", null, null, false);
     while (msgEnum.hasMoreElements()) {
         // get message
         msg = (MQeMsgObject) msgEnum.nextElement();
         //msg =msgEnum.getNextMessage(null,MQe.uniqueValue());
         // confirm get
         QMgr.confirmGetMessage(msgEnum.getQueueManagerName(),
             msgEnum.getQueueName(),
             msg.getMsgUIDFields());
     }
 } catch (Exception e) {
     System.err.println("Failure ! " + e.toString());
 }
 return msg;
 
 

Websphere MQ Everyplace