Put message rule - examples
/* Only allow msgs containing an ID field to be placed on the Queue */ public void putMessage( String destQMgr, String destQ, MQeMsgObject msg, MQeAttribute attribute, long confirmId ) { if ( !(msg.Contains( MQe.Msg_MsgId )) ) { throw new MQeException( Except_Rule, "Msg must contain an ID" ); } }
MQERETURN myRules_putMessage( MQeRulesPutMessage_in_ * pInput, MQeRulesPutMessage_out_ * pOutput) { // Only allow msgs containing an ID field to be placed on the Queue MQERETURN rc = MQERETURN_OK; MQEBOOL contains = MQE_FALSE; MQeExceptBlock * pExceptBlock=(MQeExceptBlock*)(pOutput->pExceptBlock); SET_EXCEPT_BLOCK_TO_DEFAULT(pExceptBlock); rc = mqeFields_contains(pInput->hMsg,pExceptBlock, &contains, MQE_MSG_MSGID); if(MQERETURN_OK == rc && !contains) { SET_EXCEPT_BLOCK( pExceptBlock, MQERETURN_RULES_DISALLOWED_BY_RULE, MQEREASON_NA); } }
Parent topic: Using queue manager rules