< Previous | Next >

Building the request flow

Build the request flow for the getQuote operation: create the mediation primitives, set their properties, and wire the flow.

When you connect source and target operations, a request flow and a response flow are created for each source operation that is connected. Select the source operation to view the request flow. The flow is represented from left to right. You will see an input node on the left. This is where the request message enters the flow. On the right are two callout nodes, one for each target operation. You will also see an ImmediateResponse node. This node is used when a message is to be returned to the client after the flow is executed. We will not use this node in our sample. You will add mediation primitives between the input and callout nodes and wire the flow. The completed request flow is shown below:
Screenshot of StockQuote_MediationFlow component's request flow

To build the request flow, complete the following steps:

  1. In the Operation connections section at the top of the editor, select the source interface's getQuote operation. You will see the request flow with an input and a callout for each target operation. You can now add mediation primitives and wire the request flow.
  2. Click the Request: getQuote tab in the middle section. Click the Tracing palette category to expand the group.
  3. Click the Message Logger primitive and drop it onto the request flow canvas, and rename the primitive Log.
    Screenshot of MessageLogger primitive
  4. Select a Database Lookup primitive from the Transformation palette group, drop it onto the request flow canvas, and name it Lookup.
  5. Select a Message Filter primitive from the Routing palette group, drop it onto the request flow canvas, and name it Filter.
  6. Select an XSL Transformation primitive from the Transformation palette group, drop it onto the request flow canvas, and name it TransformToDelayed.
  7. Select another XSL Transformation primitive from the palette, drop it onto the request flow canvas, and name it TransformToRealtime.
  8. Right-click the Filter primitive and select Add Output Terminal. In the Terminal name field, type realtime and click OK.
    Add Output Terminal
    You will create an XPath expression and associate it with this terminal in step 13.
  9. In the request flow canvas, wire the primitives:
    • The output terminal of getQuote : StockQuoteService to the input terminal of Log
    • The output terminal of Log to the input terminal of Lookup
    • The output terminal of Lookup to the input terminal of Filter
    • The default terminal of Filter to the input terminal of TransformToDelayed
    • The realtime terminal of Filter (created in step 8) to the input terminal of TransformToRealtime
    • The output terminal of TransformToDelayed to the input terminal of getQuote : DelayedServicePortTypePartner
    • The output terminal of TransformToRealtime to the input terminal of getQuote : RealtimeServicePortTypePartner
  10. We will now add the business object that was created earlier to the correlation context of the input node getQuote : StockQuoteService. This will allow the property subscriptionLevel to persist in the message flow. Click getQuote : StockQuoteService input node and switch to the Details tab in the Properties view. In the Correlation context field, click Browse. Select SubscriptionInformation under matching data types, and click OK. {http://Resources}SubscriptionInformation now appears in the Correlation context .
    Correlation Context added to Input node
  11. Click Log in the request flow canvas to see the primitive's properties in the Properties view. Click the Details tab to view the properties. Use the default database to log the message. Enter these properties:
    Table 1. Message Logger properties
    Property Value
    Data source name jdbc/mediation/messageLog
    Root /
    Transaction mode Same
    Message Logger details
    Root specifies the part of the message to be logged. '/' logs the complete message while '/body' logs only the body of the message.
  12. Click Lookup in the request flow canvas, and enter these property values in the Details tab:
    Table 2. Database Lookup properties
    Property Value
    Data source name jdbc/sample/CustomerDatabase
    Table CUSTOMERTABLE
    Search column CUSTOMERID
    Search location Click Edit.... In the XPath Expression Builder, navigate to/body/getQuote/request/customerID and double click on customerID. The path appears in the XPath Expression section of the builder. Click Finish.
    Using the XPath Expression Builder to define KeyPath
    In the Data elements table, click Add... and enter the following values:
    Table 3. Data elements table properties
    Column Value
    Column SUBSCRIPTIONLEVEL
    Type String
    Target location /context/correlation/subscriptionLevel
    Leave Validate input unchecked.
    Database Lookup details
  13. Click Filter in the request flow canvas. The default is to map to TransformToDelayed. The pattern for mapping to TransformToRealtime must be set. Select the Details view:
    Table 4. Message Filter properties
    Property Value
    Distribution mode First
    In the Filter table, click Add... and enter the following values:
    Table 5. Filter table properties
    Column Value
    Pattern /context/correlation/subscriptionLevel[self::node()="premium"]
    Terminal name realtime
    Message Filter details
  14. A promoted property can be changed by an administrator at runtime. The pattern property can be changed at runtime to change the quality of service. To promote the pattern property:
    1. Click the Promoted properties tab.
    2. Click the promoted check box of the pattern property.
    3. Click the alias Filter1.filters1. Type PREMIUM_SERVICE to rename the alias.
    Message Filter promoted properties view
  15. Set the properties for the XSL Transformation primitive TransformToDelayed:
    1. Select the TransformToDelayed primitive in the request flow canvas and double-click it.
    2. Click Next to see the root, input, and output message types that will be mapped. Click Finish to accept the defaults. This launches the mapping editor.
    3. On the left side, the Input object side, expand body > getQuote > request. In the Output object side, the right side, expand body. Click symbol on the left side and drag it to symbol on the right side to wire them together and create the mapping.
      Mapping Editor
    4. Save your changes and close the mapping editor. The mapping file is displayed in the Details tab of the Properties view.
      TransformToDelayed details
  16. Similarly, set the properties for the XSL Transformation primitive TransformToRealtime:
    1. Select the TransformToRealtime primitive in the request flow canvas and double-click it.
    2. The New XML Mapping wizard opens. Click Next to see the root, input, and output message types that will be mapped. Click Finish to accept the defaults, this opens the mapping editor.
    3. On the left side, expand body > getQuote > request. On the right side, expand body. Click symbol on the left side and drag it to symbol on the right side to create the mapping.
    4. Save your changes and close the mapping editor. The mapping file is displayed in the Details tab of the Properties view.
      TransformToRealtime details
  17. Save the request flow.
    Completed Request Flow

Feedback

(C) Copyright IBM Corporation 2005, 2008. All Rights Reserved.

< Previous | Next >