Websphere Message Broker 8.0 Hands-on Training – LabWebsphere Message Broker 8.0 Hands-on Training...

17
Websphere Message Broker 8.0 Hands-on Training – Lab Overview What this lab is about In this Lab you will know, how to use publish and subscribe MQ applications in the message flow and how this publish and subscribe feature of MB can be used for accounting and statistics, the monitoring function, and for message communication between internal product components by effectively utilizing the publication engine. . Introduction Publish/subscribe is a style of messaging application in which the providers of information (publishers) are decoupled from the consumers of that information (subscribers). In a publish/subscribe system, a publisher does not need to know who uses the information (publication) that it provides, and a subscriber does not need to know who provides the information that it receives as the result of a subscription. A typical publish/subscribe system has more than one publisher and more than one subscriber, and often more than one queue manager. An application can be both a publisher and a subscriber. The publisher generates a message that it wants to publish and defines the topic of the message. A subscriber registers a request for a publication by specifying one of the following items: The topic, or topics, of the published messages that it is interested in. The subscription point from which it wants to receive publications. The content filter that should be applied to the published message. The name of the queue (known as the subscriber queue) on which publications that match the criteria selected are placed. This queue can be a cluster queue, so that publications can be distributed to clustered subscribers. What you will do in this lab You will go through each step in the following sections. Each step might contain many subsets. Key Steps are: How to create an Application How to create a message flow using publish and subscribe How to Test the Message flow order How to create topic which can be used to publish and subscribe functionality

Transcript of Websphere Message Broker 8.0 Hands-on Training – LabWebsphere Message Broker 8.0 Hands-on Training...

Page 1: Websphere Message Broker 8.0 Hands-on Training – LabWebsphere Message Broker 8.0 Hands-on Training – Lab STEP 5: Double click on Publish_MF.msgflow and drag MQInput node, Compute

Websphere Message Broker 8.0 Hands-on Training – Lab

Overview

What this lab is about

In this Lab you will know, how to use publish and subscribe MQ applications in themessage flow and how this publish and subscribe feature of MB can be used foraccounting and statistics, the monitoring function, and for message communicationbetween internal product components by effectively utilizing the publication engine..Introduction

Publish/subscribe is a style of messaging application in which the providers of information (publishers) are decoupled from the consumers of that information (subscribers).

In a publish/subscribe system, a publisher does not need to know who uses the information (publication) that it provides, and a subscriber does not need to know who provides the information that it receives as the result of a subscription.

A typical publish/subscribe system has more than one publisher and more than one subscriber, and often more than one queue manager. An application can be both a publisher and a subscriber.

The publisher generates a message that it wants to publish and defines the topic of the message.

A subscriber registers a request for a publication by specifying one of the following items:

The topic, or topics, of the published messages that it is interested in. The subscription point from which it wants to receive publications. The content filter that should be applied to the published message. The name of the queue (known as the subscriber queue) on which publications

that match the criteria selected are placed. This queue can be a cluster queue, so that publications can be distributed to clustered subscribers.

What you will do in this lab

You will go through each step in the following sections. Each step might contain manysubsets.

Key Steps are:How to create an ApplicationHow to create a message flow using publish and subscribeHow to Test the Message flow orderHow to create topic which can be used to publish and subscribe functionality

Page 2: Websphere Message Broker 8.0 Hands-on Training – LabWebsphere Message Broker 8.0 Hands-on Training – Lab STEP 5: Double click on Publish_MF.msgflow and drag MQInput node, Compute

Websphere Message Broker 8.0 Hands-on Training – Lab

How to deploy the message flow

STEP 1: Click on File ->New ->Application to Create a new application. OR

Press ALT+SHIFT+N and click on Application to create new application.

STEP 2: Create new application by specifying the name as Publish_Subscribe and click on Finish.

Page 3: Websphere Message Broker 8.0 Hands-on Training – LabWebsphere Message Broker 8.0 Hands-on Training – Lab STEP 5: Double click on Publish_MF.msgflow and drag MQInput node, Compute

Websphere Message Broker 8.0 Hands-on Training – Lab

STEP 3: Right Click on (New…) under Publish_Subscribe Application name & Select Message Flow to create a Publisher Message Flow.

Page 4: Websphere Message Broker 8.0 Hands-on Training – LabWebsphere Message Broker 8.0 Hands-on Training – Lab STEP 5: Double click on Publish_MF.msgflow and drag MQInput node, Compute

Websphere Message Broker 8.0 Hands-on Training – Lab

STEP 4: Name the new message flow as Publish_MF and click on Finish.

Page 5: Websphere Message Broker 8.0 Hands-on Training – LabWebsphere Message Broker 8.0 Hands-on Training – Lab STEP 5: Double click on Publish_MF.msgflow and drag MQInput node, Compute

Websphere Message Broker 8.0 Hands-on Training – Lab

STEP 5: Double click on Publish_MF.msgflow and drag MQInput node, Compute node and Publication node from the Websphere MQ drawer, Transformation drawer and Routing drawer respectively in the MB design Palette.

Page 6: Websphere Message Broker 8.0 Hands-on Training – LabWebsphere Message Broker 8.0 Hands-on Training – Lab STEP 5: Double click on Publish_MF.msgflow and drag MQInput node, Compute

Websphere Message Broker 8.0 Hands-on Training – Lab

STEP 6: Connect the MQInput node Out terminal to Compute node and Compute node Out terminal to Publication node as shown in the picture by using connection from the palette.

Page 7: Websphere Message Broker 8.0 Hands-on Training – LabWebsphere Message Broker 8.0 Hands-on Training – Lab STEP 5: Double click on Publish_MF.msgflow and drag MQInput node, Compute

Websphere Message Broker 8.0 Hands-on Training – Lab

STEP 7: Right click on the MQInput node and select properties; specify the node name as PublishQueue under Description and specify the queue name as PublishQueue under Basic Properties as specified in the picture.

Page 8: Websphere Message Broker 8.0 Hands-on Training – LabWebsphere Message Broker 8.0 Hands-on Training – Lab STEP 5: Double click on Publish_MF.msgflow and drag MQInput node, Compute

Websphere Message Broker 8.0 Hands-on Training – Lab

STEP 8: Right click on the Compute node and select properties; specify the node nameas Publish_Compute_Node.

Page 9: Websphere Message Broker 8.0 Hands-on Training – LabWebsphere Message Broker 8.0 Hands-on Training – Lab STEP 5: Double click on Publish_MF.msgflow and drag MQInput node, Compute

Websphere Message Broker 8.0 Hands-on Training – Lab

STEP 9: Right Click on Compute node and click on Open ESQL to write the ESQL codeto do specific operations on the input message.

Page 10: Websphere Message Broker 8.0 Hands-on Training – LabWebsphere Message Broker 8.0 Hands-on Training – Lab STEP 5: Double click on Publish_MF.msgflow and drag MQInput node, Compute

Websphere Message Broker 8.0 Hands-on Training – Lab

STEP 10: Write the ESQL code as follows in the Publish_Compute_Node..Copy the code after --CALL CopyEntireMessage();, before RETURN TURE;

CREATE COMPUTE MODULE Publisher_MF_ComputeCREATE FUNCTION Main() RETURNS BOOLEANBEGIN

-- CALL CopyMessageHeaders();--CALL CopyEntireMessage(); SET OutputRoot.MQMD.Format = 'MQFMT_RF_HEADER_2'; SET OutputRoot.MQRFH2.(MQRFH2.Field)version = 2;

Page 11: Websphere Message Broker 8.0 Hands-on Training – LabWebsphere Message Broker 8.0 Hands-on Training – Lab STEP 5: Double click on Publish_MF.msgflow and drag MQInput node, Compute

Websphere Message Broker 8.0 Hands-on Training – Lab

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;RETURN TRUE;

END;

CREATE PROCEDURE CopyMessageHeaders() BEGINDECLARE I INTEGER 1;DECLARE J INTEGER;SET J = CARDINALITY(InputRoot.*[]);WHILE I < J DO

SET OutputRoot.*[I] = InputRoot.*[I];SET I = I + 1;

END WHILE;END;

CREATE PROCEDURE CopyEntireMessage() BEGINSET OutputRoot = InputRoot;

END;END MODULE;

There are two ways in which we can register to the Subscription

1. Using the Subscription message flow that we have developed.2. Using RFHUTIL.

STEP 11 : Using the Subscription message flow that we have developed.

Import the Subscribe_MF.msgflow into the toolkit as shown.

Page 12: Websphere Message Broker 8.0 Hands-on Training – LabWebsphere Message Broker 8.0 Hands-on Training – Lab STEP 5: Double click on Publish_MF.msgflow and drag MQInput node, Compute

Websphere Message Broker 8.0 Hands-on Training – Lab

STEP 12 : Right click on the Subscribe_MF.msgflow->deploy and select the default execution group and then click on Finish.

Page 13: Websphere Message Broker 8.0 Hands-on Training – LabWebsphere Message Broker 8.0 Hands-on Training – Lab STEP 5: Double click on Publish_MF.msgflow and drag MQInput node, Compute

Websphere Message Broker 8.0 Hands-on Training – Lab

STEP 11: Right Click on the Publish_MF.msgflow->deploy and select the default execution group and then click on Finish.

Page 14: Websphere Message Broker 8.0 Hands-on Training – LabWebsphere Message Broker 8.0 Hands-on Training – Lab STEP 5: Double click on Publish_MF.msgflow and drag MQInput node, Compute

Websphere Message Broker 8.0 Hands-on Training – Lab

STEP 12: Right click on the Default Execution group and select Launch Debugger port and click on ok to start the debugger.

Note: Before Launching debugger port, add breakpoints for the entire flow by right clicking on MQInput node in Publish_MF.msgflow.

Page 15: Websphere Message Broker 8.0 Hands-on Training – LabWebsphere Message Broker 8.0 Hands-on Training – Lab STEP 5: Double click on Publish_MF.msgflow and drag MQInput node, Compute

Websphere Message Broker 8.0 Hands-on Training – Lab

STEP 13: Create SubscribeQueue, PublishQueue and SUB as three queues in MQ for testing the input message.

Note: One has to open the MQ explorer to put the message.

STEP 14: First put the message in SubscribeQueue and then in the PublishQueue, then you can see the message in SUB queue due to publish and subscribe properties configured under message flow.

STEP 15: Using RFHUTIL to register the subscription

Open RFHUTIL.

Page 16: Websphere Message Broker 8.0 Hands-on Training – LabWebsphere Message Broker 8.0 Hands-on Training – Lab STEP 5: Double click on Publish_MF.msgflow and drag MQInput node, Compute

Websphere Message Broker 8.0 Hands-on Training – Lab

Click on Pub Sub Tab and Enter Subscription Queue Manager and Subscription Queue names

Page 17: Websphere Message Broker 8.0 Hands-on Training – LabWebsphere Message Broker 8.0 Hands-on Training – Lab STEP 5: Double click on Publish_MF.msgflow and drag MQInput node, Compute

Websphere Message Broker 8.0 Hands-on Training – Lab

STEP 16: First put the message in SubscribeQueue and then in the PublishQueue, then you can see the message in SUB queue due to publish and subscribe properties configured under message flow.