When this API call returns, the unique identifier (UID) is set in the input message object, and it is set every time this API is called. So an application can call this API with the same input message object and the UID is set with a different value every time. This resetting mechanism guarantees that no message object with a duplicate UID enters the WebSphere MQ Everyplace network.
The application must call MQeFieldsFree to deallocate the message handle hMsg .
#include <hmq.h> MQEVOID MQeQMgrPutMsg( MQEHSESS hSess, MQECHAR * pQMName, MQECHAR * pQName, MQEVOID * pPutMsgOpts, MQEHFIELDS hMsg, MQEINT32 * pCompCode, MQEINT32 * pReason)
typedef struct tagMQePutMsgOpts{ MQECHAR StrucId[4]; /* Input */ MQEINT32 Version; /* Input */ MQEINT32 Options; /* Input */ MQEINT64 ConfirmId; /* Input */ MQEHATTRB hAttrb; /* Input */ } MQEPMO;
The default value is MQE_QMGR_OPTION_NONE.
The 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 MQEPMO data structure with the default values is used.
#include <hmq.h> static const MQECHAR pHello[] = "Hello world."; MQEHSESS hSess; MQEHFIELDS hMsg; MQEINT32 rc; MQEINT32 compcode; MQEINT32 reason; MQEPMO pmo = MQEPMO_DEFAULT; MQECHAR * qm, *q; qm = "aQM"; q = "QQ"; hSess = MQeInitialize("MyAppsName", &compcode, &reason); hMsg = MQeFieldsAlloc( hSess, MQE_OBJECT_TYPE_MQE_MSGOBJECT, &compcode, &reason); MQeFieldsPut(hSess, hMsg, "hi", MQE_TYPE_ASCII, pHello, sizeof(pHello), &compcode, &reason); /* Put msg with confirmID*/ pmo.ConfirmId.hi = 0x2222; pmo.ConfirmId.lo = 0x1111; pmo.Options |= MQE_QMGR_OPTION_CONFIRMID; MQeQMgrPutMsg( hSess, qm, q, &pmo, hMsg, &compcode, &reason); /* Confirms the message, i.e., delete it off the queue. */ MQeQMgrConfirmMsg( hSess, qm, q, MQE_QMGR_OPTION_CONFIRM_PUTMSG, hMsg, &compcode, &reason); /* Free the message handle */ MQeFieldsFree( hSess, hMsg, &compcode, &reason); MQeTerminate( hSess, &compcode, &reason);