Wednesday, 5 October 2016

Publish and Subscribe Scenario

Step1:-
Create a flow like below Publish Messageflow
MQInputNode--->ComputeNode----->Publication Node

Configuration on Nodes:-
MQInputNode:-
Queuename: PublishQueue
Input Message Parsing: XMLNSC

ComputeNode:-

   SET OutputRoot.MQMD.Format =  'MQFMT_RF_HEADER_2';
 SET OutputRoot.MQRFH2.(MQRFH2.Field)version = 2;
 SET OutputRoot.MQRFH2.(MQRFH2.Field)Format = 'MQSTR';
 SET OutputRoot.MQRFH2.(MQRFH2.Field)NameValuCCSID=1208;
 SET OutputRoot.MQRFH2.psc.Command='Publish';
 SET OutputRoot.MQRFH2.psc.Topic = InputRoot.XMLNSC.publish.topic;
 Declare PTR REFERENCE to OutputRoot.MQRFH2;
 Detach PTR;
 attach PTR TO OutputRoot.MQMD AS NEXTSIBLING ;
 SET OutputRoot.XMLNSC.data.info = InputRoot.XMLNSC.publish.info;

Publication Node:-
No configuration needed.

Test Input:-
 <publish><topic>Bhanu</topic><info>Sample</info></publish> Put this Message in  PublishQueue
to publish

Step2:-
Create a flow like below Subscribe Messageflow
MQInputNode--->ComputeNode----->MQOutput Node

Configuration on Nodes:-
MQInputNode:-
Queuename: Subscription
Input Message Parsing: XMLNSC

ComputeNode:-

   SET OutputRoot.MQMD.Format =  'MQFMT_RF_HEADER_2';
 SET OutputRoot.MQRFH2.(MQRFH2.Field)version = 2;
 SET OutputRoot.MQRFH2.(MQRFH2.Field)Format = 'MQSTR';
 SET OutputRoot.MQRFH2.(MQRFH2.Field)NameValuCCSID=1208;
 SET OutputRoot.MQRFH2.psc.Command ='RegSub';
 SET OutputRoot.MQRFH2.psc.Topic = InputRoot.XMLNSC.subscribe.topic;
 SET OutputRoot.MQRFH2.psc.QName = 'RegSub';
 SET OutputRoot.MQRFH2.psc.QMgrName ='TEST';
DECLARE PTR REFERENCE TO OutputRoot.MQRFH2;
 Detach PTR;
 attach PTR TO OutputRoot.MQMD AS NEXTSIBLING ;

MQOutput Node:-
Queuename: SYSTEM.BROKER.CONTROL.QUEUE 

Test Input:-
<subscribe><topic>Bhanu</topic></subscribe> Put this Message in  Subscription
to Subscribe.

Objects to be Created:-
Create PublishQueue,Subscription,RegSub as three queues in MQ for testing

Direction to Test:-
First put the message in Subscription and then in the  PublishQueue, then you can see the message in RegSub queue due to publish and subscribe properties configured in message flow.

No comments:

Post a Comment