Get message from a local queue

Once the message has been put to a queue, you can retrieve and check it. Similar options are passed to the getMessage function. The difference is that a pointer to a field's handle is passed in. A new Fields object is created, removing the message from the queue:
    MQeFieldsHndl hReturnedMessage; 
    display("Getting the message back \n");  
    
    rc = mqeQueueManager_getMessage(hQueueManager,
                          &exceptBlock,
                          &hReturnedMessage,
                          hLocalQMName,
                          hLocalQueueName,
                                NULL,
                                NULL,
                                0);
   }                
Once the message has been obtained, you can check it for the value that was entered. Obtain this by using the getInt32 function. If the result is valid, you can print it out:
    if (MQERETURN_OK == rc) {
      MQEINT32 answer;
       rc = mqeFields_getInt32(hReturnedMessage,
                                &exceptBlock,
                                &answer,
                                hFieldLabel);
    
    if (MQERETURN_OK == rc) {
      display("Answer is %d\n",answer);
    } 
    else {
       display("\n\n %s (0x%X) %s (0x%X)\n",
           mapReturnCodeName(EC(&exceptBlock)),
           EC(&exceptBlock),
           mapReasonCodeName(ERC(&exceptBlock)),
           ERC(&exceptBlock)  );
      }
  
    }

Terms of use | WebSphere software

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