Example (C) - assured get

This example code is taken from the examples.application.example6 example program.

MQEINT32 maxRetry = 5;

rc = mqeQueueManager_getMessage(hQMgr,
                           &exceptBlock,
                              hQMgrName,
                              hQName, hMsg,
                              NULL, confirmId);

/* if the get attempt fails, retry 
    up to the maximum number of*/ 
/*retry times permitted, 
  setting the re-send flag. */
while (MQERETURN_OK != rc  && 
                           --maxRetry > 0 ) {
    rc = mqeFields_getBoolean(hMsg,
                         &exceptBlock,
                            MQE_MSG_RESEND,
                            MQE_TRUE);
    if(MQERETURN_OK == rc) {
        rc = mqeQueueManager_getMessage(hQMgr,
                                &exceptBlock,
                                   hQMgrName,
                                   hQName, hMsg,
                                   NULL,
                                   confirmId);
    }
}

if(MQERETURN_OK == rc) {
    MQeFieldsHndl hFilter;
    maxRetry = 5;
    rc = mqeFieldsHelper_getMsgUidFields(hMsg,
                                   &exceptBlock,
                                   &hFilter);
    if(MQERETURN_OK == rc) {
          rc = mqeQueueManager_confirmGetMessage(hQMgr,
                                        &exceptBlock,
                                           hQMgrName,
                                           hQName,
                                           hFilter);
    }
     while (MQERETURN_OK != rc  && 
                          --maxRetry > 0 ) {
             rc = mqeQueueManager_confirmPutMessage(hQMgr,
                                             &exceptBlock,
                                                hQMgrName,
                                                hQName,
                                                hFilter);
    }
}

Terms of use | WebSphere software

(c) Copyright IBM Corporation 2004, 2005. All rights reserved.