implementing publication flow

Upload: shopmanual

Post on 05-Apr-2018

217 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/31/2019 Implementing Publication Flow

    1/13

    Technology Integration Centers

    IMPLEMENTING PUBLICATION FLOW

    Accenture Innovation Center for IBM Technologies

    Implementing Publication Flow

    6/28/2012 Accenture Innovation Center for IBM TechnologiesPage 1

  • 7/31/2019 Implementing Publication Flow

    2/13

    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 Accenture Innovation Center for IBM TechnologiesPage 2

  • 7/31/2019 Implementing Publication Flow

    3/13

    Technology Integration Centers

    IMPLEMENTING PUBLICATION FLOW

    Date of Revision Revision Made By Version Number Description of Change11/10/2009 Andrzej Adamczyk 1.0 Initial Draft

    6/28/2012 Accenture Innovation Center for IBM TechnologiesPage 3

  • 7/31/2019 Implementing Publication Flow

    4/13

    Technology Integration Centers

    IMPLEMENTING PUBLICATION FLOW

    1. IntroductionThis document contains guide on how to implement set of message flows that participate in publish subscribemessaging pattern.

    2. Message Flows OverviewDemo broker application contains single publication flow that publishes message to different topics and multiplemessage flows that subscribe to these topics. Publication flow receives single stock quote message. It sends themessage with USD stock price to finance/news/stocks topic. It also converts USD price into price in EUR and JPY andsends appropriate messages to finance/news/stocks/eur and finance/news/stocks/jpy topics. Subscribed to those topicsare message flows that save current quotes to files and one message flow that generates stock news feed using price inEUR.

    PUBLICATION_IN Publication Flow

    Topic

    Topic

    Topic

    STOCK_USD

    STOCK_JPY

    STOCK_EUR

    NEWS_EUR

    Subscriber FlowSave Quote in

    USD

    Subscriber Flow

    Save Quote in

    JPY

    Subscriber FlowSave Quote in

    EUR

    Subscriber Flow

    Create News Feed

    3. Publication Flow ImplementationPublication flow retrieves stock quote message from the queue and sends it to multiple different topics, each timemodifying the price for specific currency.

    1) Create new PublishSubscribeMS message set project.

    6/28/2012 Accenture Innovation Center for IBM TechnologiesPage 4

  • 7/31/2019 Implementing Publication Flow

    5/13

    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 Accenture Innovation Center for IBM TechnologiesPage 5

  • 7/31/2019 Implementing Publication Flow

    6/13

  • 7/31/2019 Implementing Publication Flow

    7/13

    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 parserdomain.

    10) In advanced properties section set default topic to finance/news/stocks. This is the topic to which we will sendall stock quotes in USD. By setting this property we instruct MQInput node to set Properties/Topic element ofthe 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.brokerpackage. 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 Accenture Innovation Center for IBM TechnologiesPage 7

  • 7/31/2019 Implementing Publication Flow

    8/13

    Technology Integration Centers

    IMPLEMENTING PUBLICATION FLOW

    12) Add following constants to ConvertToEUR class.

    privatestaticfinaldoubleEXCHANGE_RT = 0.6d;

    privatestaticfinal 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 toConvertToEUR class. The difference is that ConvertToJPY sets different topic string and modifies stock quotemessage to contain price in Japanese yen.

    15) Add following constants to the class.

    privatestaticfinaldoubleEXCHANGE_RT = 0.6d;

    privatestaticfinal 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 Accenture Innovation Center for IBM TechnologiesPage 8

  • 7/31/2019 Implementing Publication Flow

    9/13

    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 Accenture Innovation Center for IBM TechnologiesPage 9

  • 7/31/2019 Implementing Publication Flow

    10/13

    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 filename.

    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 Accenture Innovation Center for IBM TechnologiesPage 10

  • 7/31/2019 Implementing Publication Flow

    11/13

    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 Accenture Innovation Center for IBM TechnologiesPage 11

  • 7/31/2019 Implementing Publication Flow

    12/13

    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 Accenture Innovation Center for IBM TechnologiesPage 12

  • 7/31/2019 Implementing Publication Flow

    13/13

    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 Accenture Innovation Center for IBM TechnologiesPage 13