Putting messages onto a queue

To put a message object onto a queue, use the MQeQMgrPutMsg API. This function takes a queue manager name and queue name pair. Since WebSphere MQ Everyplace on the Palm has no local queue capability, it runs as a synchronous client to a WebSphere MQ Everyplace remote queue manager. The queue manager name input parameter must be a remote queue manager.

MQeQMgrPutMsg takes an MQEPMO data structure as an input.

Note:
Only the ConfirmId option is supported in WebSphere MQ Everyplace Version 2.0.0.5.

The ConfirmId option is used to implement assured message delivery between the WebSphere MQ Everyplace client and the server. When you specify this option with MQeQMgrPutMsg, the message is put onto the queue, but it is not made accessible until an MQeQMgrConfirmMsg is called on the message object. The application issues an MQeQMgrConfirmMsg call only after the MQeQMgrPutMsg has successfully returned. If the communication link fails during an MQeQMgrPutMsg call, the application should first call an MQeQMgrUndo when connection with the WebSphere MQ Everyplace server is reestablished. This call removes the message that may or may not have been put on the queue with the previous MQeQMgrPutMsg. The application can then safely call an MQeQMgrPutMsg again, followed by an MQeQMgrConfirmMsg call.

These procedures are shown in the following code fragment.

#include <hmq.h>
static const MQECHAR pHello[] = "Hello world.";
MQEHSESS   hSess;
MQEHFIELDS hMsg;
MQEINT32   rc;
MQEINT32   compcode;
MQEINT32   reason;
MQEPMO     pmo = MQEPMO_DEFAULT; /* Defaul option */
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 message WITHOUT confirm */
MQeQMgrPutMsg( hSess, qm, q, &pmo, hMsg, 
					&compcode	&reason);
 
/* Put it again.  This is equivalent to the previous call */
MQeQMgrPutMsg( hSess, qm, q, NULL, hMsg, 
					&compcode	&reason);
 
 
/* Put msg with confirmID, follow by a ConfirmMsg() */
 
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);
 
/* Put msg with confirmID, follow by a Undo() */
 
pmo.ConfirmId.hi = 0xabab;
pmo.ConfirmId.lo = 0xcdda;
pmo.Options     |= MQE_QMGR_OPTION_CONFIRMID;
 
MQeQMgrPutMsg( hSess, qm, q, &pmo, hMsg, 
					&compcode	&reason);
 
/* Undo the PutMsg(), i.e., delete it off the queue. */
MQeQMgrUndo( hSess, qm, q, pmo.ConfirmId, 
					&compcode	&reason);
 
/* Free the message handle */
MQeFieldsFree( hSess, hMsg, &compcode	&reason);
 
MQeTerminate( hSess, &compcode	&reason);
 


© IBM Corporation 2002. All Rights Reserved