#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™ code base, the rules implementation is linked to the execution life cycle of a single queue manager and may not be replaced during the course of this life cycle.