0% found this document useful (0 votes)
50 views

Implementing Publication Flow

This document provides instructions for implementing publication and subscription flows for a publish-subscribe messaging pattern using IBM Integration Bus. It describes creating a publication flow that receives stock quotes and publishes modified messages to different topics, and several subscriber flows that listen to topics and save quotes to files or generate news feeds. Implementation details are given for creating the message flows, mapping messages, and processing stock price conversions in Java compute nodes.

Uploaded by

shop_manual
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views

Implementing Publication Flow

This document provides instructions for implementing publication and subscription flows for a publish-subscribe messaging pattern using IBM Integration Bus. It describes creating a publication flow that receives stock quotes and publishes modified messages to different topics, and several subscriber flows that listen to topics and save quotes to files or generate news feeds. Implementation details are given for creating the message flows, mapping messages, and processing stock price conversions in Java compute nodes.

Uploaded by

shop_manual
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 13

Technology Integration Centers

IMPLEMENTING PUBLICATION FLOW

Accenture Innovation Center for IBM Technologies


Implementing Publication Flow

6/28/2012 Page 1

Accenture Innovation Center for IBM Technologies

Technology Integration Centers


IMPLEMENTING PUBLICATION FLOW

1.Introduction...............................................................................................................................................................4 2.Message Flows Overview.........................................................................................................................................4 3.Publication Flow Implementation...........................................................................................................................4 4.Subscriber Flows Implementation..........................................................................................................................9

6/28/2012 Page 2

Accenture Innovation Center for IBM Technologies

Technology Integration Centers


IMPLEMENTING PUBLICATION FLOW

Date of Revision
11/10/2009

Revision Made By
Andrzej Adamczyk

Version Number
1.0

Description of Change
Initial Draft

6/28/2012 Page 3

Accenture Innovation Center for IBM Technologies

Technology Integration Centers


IMPLEMENTING PUBLICATION FLOW

1. Introduction
This document contains guide on how to implement set of message flows that participate in publish subscribe messaging pattern.

2. Message Flows Overview


Demo broker application contains single publication flow that publishes message to different topics and multiple message flows that subscribe to these topics. Publication flow receives single stock quote message. It sends the message with USD stock price to finance/news/stocks topic. It also converts USD price into price in EUR and JPY and sends appropriate messages to finance/news/stocks/eur and finance/news/stocks/jpy topics. Subscribed to those topics are message flows that save current quotes to files and one message flow that generates stock news feed using price in EUR.
Subscriber Flow Save Quote in USD

Topic

STOCK_USD

PUBLICATION_IN

Publication Flow

Topic

STOCK_JPY

Subscriber Flow Save Quote in JPY

STOCK_EUR

Subscriber Flow Save Quote in EUR

Topic

NEWS_EUR

Subscriber Flow Create News Feed

3. Publication Flow Implementation


Publication flow retrieves stock quote message from the queue and sends it to multiple different topics, each time modifying the price for specific currency. 1) Create new PublishSubscribeMS message set project.

6/28/2012 Page 4

Accenture Innovation Center for IBM Technologies

Technology Integration Centers


IMPLEMENTING PUBLICATION FLOW 2) Select XMLNSC parser domain for that message set.

3) Create Stock message definition within message set.

6/28/2012 Page 5

Accenture Innovation Center for IBM Technologies

Technology Integration Centers


IMPLEMENTING PUBLICATION FLOW 4) Within Stock message definition create 2 complex types: Stock Quote and Stock News, and 2 messages of those types.

5) Create new PublishSubscribeUseCase message flow project. 6) Create message flow in the default broker schema, named PublicationFlow. 7) Open message flow and drag and drop MQInput node, 2 Java compute nodes and 3 Publication nodes.

6/28/2012 Page 6

Accenture Innovation Center for IBM Technologies

Technology Integration Centers


IMPLEMENTING PUBLICATION FLOW 8) Set MQInput node queue name to PUBLICATION_IN queue.

9) Set MQInput node message parsing properties to use PublishSubscribeMS message set and XMLNSC parser domain.

10) In advanced properties section set default topic to finance/news/stocks. This is the topic to which we will send all stock quotes in USD. By setting this property we instruct MQInput node to set Properties/Topic element of the message tree. This element is used by Publication node to retrieve topic name, unless RFH2 header exists.

11) Provide implementation to ConvertToEUR java compute node. Place java class in com.accenture.aicit.broker package. The method of this class overwrites default value of Message/Topic element (set by MQInput node) and modifies stock quote message to contain price in euro.

6/28/2012 Page 7

Accenture Innovation Center for IBM Technologies

Technology Integration Centers


IMPLEMENTING PUBLICATION FLOW 12) Add following constants to ConvertToEUR class. private static final double EXCHANGE_RT = 0.6d; private static final String TOPIC_STR = "finance/news/stocks/eur"; 13) Modify evaluate() method code by adding following lines in section specified for user code. MbElement root = outMessage.getRootElement(); // set topic MbElement topic = root.getFirstElementByPath("Properties/Topic"); topic.setValue(TOPIC_STR); // set new currency symbol MbElement currency = root.getFirstElementByPath("XMLNSC/StockQuote/Currency"); currency.setValue("EUR"); // convert stock price MbElement price = root.getFirstElementByPath("XMLNSC/StockQuote/Price"); double priceValue = Double.parseDouble(price.getValueAsString()); priceValue *= EXCHANGE_RT; price.setValue(String.valueOf(priceValue)); 14) Provide implementation of ConvertToJPY java compute node. The implementation of this class is very similar to ConvertToEUR class. The difference is that ConvertToJPY sets different topic string and modifies stock quote message to contain price in Japanese yen. 15) Add following constants to the class. private static final double EXCHANGE_RT = 0.6d; private static final String TOPIC_STR = "finance/news/stocks/jpy"; 16) Modify evaluate() method implementation by adding following lines MbElement root = outMessage.getRootElement(); // set topic MbElement topic = root.getFirstElementByPath("Properties/Topic"); topic.setValue(TOPIC_STR); // set new currency symbol MbElement currency = root.getFirstElementByPath("XMLNSC/StockQuote/Currency"); currency.setValue("JPY"); // convert stock price MbElement price = root.getFirstElementByPath("XMLNSC/StockQuote/Price"); double priceValue = Double.parseDouble(price.getValueAsString()); priceValue *= EXCHANGE_RT; price.setValue(String.valueOf(priceValue));

6/28/2012 Page 8

Accenture Innovation Center for IBM Technologies

Technology Integration Centers


IMPLEMENTING PUBLICATION FLOW

4. Subscriber Flows Implementation


1) Create new EURSubscriberFlow message flow in default broker schema. 2) Drag and drop onto canvas MQInput node and FileOutput node.

3) Set queue name in MQInput node to STOCK_EUR queue.

4) Set message domain to XMLNSC and message set to PublishSubscribeMS.

5) In the Basic properties section of the FileOutput node set output directory to c:\temp\eur

6/28/2012 Page 9

Accenture Innovation Center for IBM Technologies

Technology Integration Centers


IMPLEMENTING PUBLICATION FLOW 6) In the Request section set data location to $Root/XMLNSC/StockQuote and file name to $Root/XMLNSC/StockQuote/Symbol. Those setting specify the content that will be saved to a file and the file name.

7) Create new USDSubscriberFlow message flow.

8) Set queue name in MQInput node to STOCK_USD queue.

9) Set message domain to XMLNSC and message set to PublishSubscribeMS.

10) In Basic section of FileOutput node properties set directory to c:\temp\usd. 11) In Request section set properties in the similar way as in step 6.

6/28/2012 Page 10

Accenture Innovation Center for IBM Technologies

Technology Integration Centers


IMPLEMENTING PUBLICATION FLOW 12) Create new JPYSubscriberFlow message flow.

13) Set queue name in MQInput node to STOCK_JPY.

14) Set message domain to XMLNSC and message set to PublishSubscribeMS.

15) In Basic section of FileOutput node properties set directory to c:\temp\jpy. 16) In Request section set data location and file name in similar way as in step 6. 17) Create new EURStockNewsFlow message flow. 18) Add MQInput, Mapping and MQOutput nodes to the flow.

19) Set queue name in MQInput node to NEWS_EUR queue.

6/28/2012 Page 11

Accenture Innovation Center for IBM Technologies

Technology Integration Centers


IMPLEMENTING PUBLICATION FLOW 20) Set message domain to XMLNSC and message set to PublishSubscribeMS.

21) Set queue name of MQOutput node to NEWS_OUT queue.

22) Set mapping mode of the Mapping node to Message.

23) Double click on Mapping node and implement the mapping.

6/28/2012 Page 12

Accenture Innovation Center for IBM Technologies

Technology Integration Centers


IMPLEMENTING PUBLICATION FLOW 24) Select StockQuote as an input message and StockNews as an output message.

25) Set Date element in output message to Timestamp element of the input message. 26) Set Message element of the output message to the following xPath expression. fn:concat($source/StockQuote/Symbol, ' sold for ', $source/StockQuote/Price, ' at ', fn:substring($source/StockQuote/Timestamp, 9, 2), ':', fn:substring($source/StockQuote/Timestamp, 11, 2))

6/28/2012 Page 13

Accenture Innovation Center for IBM Technologies

You might also like