Transmission rules

A message that is put to a remote queue that is defined as synchronous is transmitted immediately. Messages put to remote queues defined as asynchronous are stored within the local queue manager until the queue manager is triggered into transmitting them. The queue manager can be triggered directly by an application. The process can be modified or monitored using the queue manager's transmission rules.

The transmission rules are a subset of the queue manager rules. The two rules that allow control over message transmission are:

triggerTransmission()
This rule determines whether to allow message transmission at the time when the rule is called. This can be used to veto or allow the transmission of all messages, that is, either all or none are allowed to be transmitted.

transmit()
This rule makes a decision to allow transmission on a per queue basis for asynchronous remote queues. For example, this makes it possible only to transmit the messages from queues deemed to be high priority. The transmit() rule is only called if the triggerTransmission() rule returns successfully.

Trigger transmission rule

WebSphere MQ Everyplace 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 codebase, 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 over-ride 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 codebase
/* 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 codebase
/* 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);
    }
}


© IBM Corporation 2002. All Rights Reserved