Queue manager rules are loaded, or changed whenever a queue manager administration message containing a request to update the queue manager rule class is received.
If a queue manager rule has already been applied to the queue manager, the existing rule is asked whether it may be replaced with a different rule. If the answer is yes, the new rule is loaded and activated. A restart of the queue manager is not required.
The QueueManagerUpdater command-line tool in the package examples.administration.commandline shows how to create such an administration message.
The user's rules module is loaded and initialized when the queue manager is loaded into memory. This occurs as a result of calls either to mqeAdministrator_QueueManager_create() or to mqeQueueManager_new(). The set-up steps are as follows:
#define RULES_ALIAS "myAlias" #define MODULE_NAME "myRulesModule.dll" #define ENTRY_POINT "myRules_new" ... mqeString_newUtf8(pExceptBlock, &rulesAlias, RULES_ALIAS); mqeString_newUtf8(pExceptBlock, &moduleName, MODULE_NAME); mqeString_newUtf8(pExceptBlock, &entryPoint, ENTRY_POINT); mqeClassAlias_add(pExceptBlock, rulesAlias, moduleName, entryPoint);
MQeQueueManagerParms qmParams; qmParams.hQueueStore = msgStore; /* String parameters for the*/ /*location of the msg store */ qmParams.hQueueManagerRules = rulesAlias; /* add in rules alias */ /* Indicate what parts of the structure have been set */ qmParams.opFlags = QMGR_Q_STORE_OP | QMGR_RULES_OP; ... rc = mqeAdministrator_QueueManager_create(hAdmin,pExceptBlock, &hQM,qmName, &qmParms, ®Parms);
MQERETURN myRules_new( MQeRulesNew_in_ * pInput,MQeRulesNew_out_ * pOutput) { MQERETURN rc = MQERETURN_OK; /* declare an instance of the private data */ /*structure passed around between rules invocations. */ /*This holds user data which is 'global' between rules. */ myRules * myData = NULL; /* allocate the memory for the structure */ myData = malloc(sizeof(myRules)); if(myData != NULL) { /* map user rules implementations to function pointers in output parameter structure */ pOutput->fPtrActivateQMgr = myRules_ActivateQMgr; pOutput->fPtrCloseQMgr = myRules_CloseQMgr; pOutput->fPtrDeleteMessage = unitTestRules_DeleteMessage; pOutput->fPtrGetMessage = myRules_getMessage; pOutput->fPtrPutMessage = myRules_putMessage; pOutput->fPtrTransmitQueue = myRules_TransmitQueue; pOutput->fPtrTransmitQMgr = myRules_TransmitQMgr; pOutput->fPtrActivateQueue = myRules_activateQueue; pOutput->fPtrCloseQueue = myRules_CloseQueue; pOutput->fPtrMessageExpired = myRules_messageExpired; /* initialize data in the private data structure */ mydata->carryOn = MQE_TRUE; mydata->hAdmin = NULL; mydata->hThread = NULL; mydata->ifp = NULL; mydata->triggerInterval = 15000; /* now assign the private data structure to */ /*the output parameter structure variable */ pOutput->pPrivateData = (MQEVOID *)mydata; } else { /* We had a problem so clear up any strings in the structure - none in this case */ } return rc; }
The rules module is unloaded when the queue manager is freed. Note that, unlike the java codebase, the rules implementation is linked to the execution lifecycle of a single queue manager and may not be replaced during the course of this lifecycle.