Transmit rule - C example 1

The example rule below only allows message transmission from a queue if the queue has a default priority greater than 5. If a message has not been assigned a priority before being placed on a queue, it is given the queue's default priority.

/* The following function is mapped to the fPtrTransmitQueue function*/
/* pointer in the user's initialization 
/* function output parameter structure. */

MQERETURN myRules_TransmitQueue( MQeRulesTransmitQueue_in_ * pInput,                
                        MQeRulesTransmitQueue_out_ * pOutput) {
    MQERETURN rc = MQERETURN_OK;    
    MQEBYTE queuePriority;
      
    MQeRemoteAsyncQParms queueParms = REMOTE_ASYNC_Q_INIT_VAL;
    myRules * myData = (myRules *)(pInput->pPrivateData);

    MQeExceptBlock * pExceptBlock = 
                   (MQeExceptBlock *)(pOutput->pExceptBlock);    
    SET_EXCEPT_BLOCK_TO_DEFAULT(pExceptBlock);
    
    /* inquire upon the default priority of the queue*/
    /* specify the subject of the inquire 
      in the queue parameter structure*/
   queueParms.baseParms.opFlags =  QUEUE_PRIORITY_OP ;
    
    rc =  mqeAdministrator_AsyncRemoteQueue_inquire(myData->hAdmin,
                                     pExceptBlock,          
                                     pInput->hQueueName, 
                                     pInput->hQueue_QueueManagerName,
                                     &queueParms);
    // if the default priority is less than 6, disallow the operation
    if(MQERETURN_OK == rc 
      && queueParms.baseParms.queuePriority < 6) {
        SET_EXCEPT_BLOCK(pExceptBlock, 
                         MQERETURN_RULES_DISALLOWED_BY_RULE, 
                  MQEREASON_NA);
    }
}

Terms of use | WebSphere software

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