Trigger transmission rule example

MQe calls the triggerTransmission rule when transmission is triggered. This occurs when the queue manager triggerTransmission method or function is explicitly called from an application or a rule. Additionally, in the Java™ code base, the rule may be invoked when a message is put onto a remote asynchronous queue. The default rule behavior in both Java and C allows the attempt to transmit pending messages to proceed. For example, this is the default Java rule in com.ibm.mqe.MQeQueueManagerRule:
/* default trigger transmission rule -
    always allow transmission */
public boolean triggerTransmission(int noOfMsgs,
      MQeFields msgFields ){
    return true;
}

The return code from this rule tells the queue manager whether or not to transmit any pending messages. A return code of true means "transmit", while a return code of false means "do not transmit at this time".

The user may override the default behavior by implementing their own triggerTransmission() rule. A more complex rule can decide whether or not to transmit immediately based on the number of messages awaiting transmission on asynchronous remote queues. The following example shows a rule that only allows transmission to continue if there are more than 10 messages pending transmission.
Java code base
/* Decide to transmit based on number of pending messages */
public boolean triggerTransmission( int noOfMsgs, MQeFields msgFields ) {
    if(noOfMsgs > 10)    {
        return true; /* then transmit */
    }
    else {
        return false; /* else do not transmit */
    }
}
C code base
/* The following function is mapped to the 
    fPtrTransmitQMgr function pointer  */
/* in the user's initialization function output parameter structure. */

MQERETURN myRules_TransmitQMgr( MQeRulesTransmitQMgr_in_  * pInput,
                        MQeRulesTransmitQMgr_out_ * pOutput)    {
    MQeExceptBlock * pExceptBlock =
                        (MQeExceptBlock*)(pOutput->pExceptBlock);
    SET_EXCEPT_BLOCK_TO_DEFAULT(pExceptBlock);

   /* allow transmission to be triggered only
      if the number of pending messages > 10  */
    if(pInput->msgsPendingTransmission <= 10) {
        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.