The application programmer is responsible for calling MQeFieldsFree to deallocate the returned message handle.
#include <hmq.h> MQEHFIELDS MQeQMgrGetMsg( MQEHSESS hSess, MQECHAR * pQMName, MQECHAR * pQName, MQEVOID * pGetMsgOpts, MQEHFIELDS hFilter, MQEINT32 * pCompCode, MQEINT32 * pReason)
typedef struct tagMQeGetMsgOpts{ MQECHAR StrucId[4]; /* Input */ MQEINT32 Version; /* Input */ MQEINT32 Options; /* Input */ MQEINT64 ConfirmId; /* Input */ MQEHATTRB hAttrb; /* Input */ } MQEGMO;
The default value is MQE_QMGR_OPTION_NONE.
Default value is '0'. If MQE_QMGR_OPTION_CONFIRMID is set and ConfirmId is '0', or if ConfirmId is nonzero and MQE_QMGR_OPTION_CONFIRMID is not set, the call fails.
If this parameter is NULL, then an MQEGMO data structure with the default values is used.
#include <hmq.h> MQEHSESS hSess; MQEHFIELDS hMsg, hFilter; MQEINT32 compcode; MQEINT32 reason; MQEGMO gmo = MQEGMO_DEFAULT; MQECHAR * aKey = "aKey", * qm, *q; qm = "aQM"; q = "QQ"; hSess = MQeInitialize("MyAppsName", &compcode, &reason); /* Get msg with filter and confirmID*/ gmo.ConfirmId.hi = 0x2222; gmo.ConfirmId.lo = 0x1111; gmo.Options |= MQE_QMGR_OPTION_CONFIRMID; hFilter = MQeFieldsAlloc( hSess, MQE_OBJECT_TYPE_MQE_FIELDS, &compcode, &reason); MQeFieldsPut( hSess, hFilter, "FindThis", MQE_TYPE_ASCII, aKey, strlen(aKey), &compcode, &reason); /* Get a message that /* contains the field-name "FindThis", */ /* field-type of ASCII, and /* a field-value of "aKey". */ hMsg = MQeQMgrGetMsg( hSess, qm, q, &gmo, hFilter, &compcode, &reason); if (compcode==MQECC_OK) { /* Do something with the message. */ /* Confirms the message, i.e., delete it off the queue. */ MQeQMgrConfirmMsg( hSess, qm, q, MQE_QMGR_OPTION_CONFIRM_GETMSG, hMsg, &compcode, &reason); /* Free the message handle */ MQeFieldsFree( hSess, hMsg, &compcode, &reason); } MQeFieldsFree( hSess, hFilter, &compcode, &reason); MQeTerminate( hSess, &compcode, &reason);