Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Figure 1: Datatype Channel EIP

Example scenario

The This example scenario depicts a Stock Quote service deployed in Axis2 server. It offers several service operations to the user. The ESB uses the filter mediator to identify each action that is specified by the sender and diverts the request into the appropriate sequence. Each sequence acts as a separate channel. The sender experiences the decomposition of channels through a log message indicated by the ESB. There will be a different log message for each operation the sender requests.

The following diagram below depicts how to simulate the this example scenario can be depicted using the ESB.

Figure 2: Example scenario of the Datatype Channel EIP

...

Datatype Channel EIP (Figure 1)
Datatype Channel Example Scenario (Figure 2)
SenderClient
Datatype Channel

Filter and Sequence mediators of the ESB. The Filter Mediator specifies the datatype channel to use, and the ESB profile each datatype channel as a Sequence Mediator.

ReceiverStock Quote Service

...

Code Block
<definitions xmlns="http://ws.apache.org/ns/synapse">
   <endpoint name="StockQuoteReceiver">
       <address uri="http://localhost:9000/services/SimpleStockQuoteService"/>
   </endpoint>
   <sequence name="MarketActivity">
       <log level="custom">
           <property name="Messaging_Channel" value="MARKET_ACTIVITY"/>
       </log>
       <send>
           <endpoint key="StockQuoteReceiver"/>
       </send>
   </sequence>
   <sequence name="FullQuote">
       <log level="custom">
           <property name="Messaging_Channel" value="FULL_QUOTE"/>
       </log>
       <send>
           <endpoint key="StockQuoteReceiver"/>
       </send>
   </sequence>

   <sequence name="StockQuote">
       <log level="custom">
           <property name="Messaging_Channel" value="STOCK_QUOTE"/>
       </log>
       <send>
           <endpoint key="StockQuoteReceiver"/>
       </send>
   </sequence>
   <proxy name="datatype-channel-proxy" startOnLoad="true" transports="http https">
       <target>
           <log/>
           <inSequence>
               <switch source="get-property('Action')">
                   <case regex="/*urn:getQuote/*">
                       <sequence key="StockQuote"/>
                   </case>
                   <case regex="/*urn:getFullQuote/*">
                       <sequence key="FullQuote"/>
                   </case>
                   <case regex="/*urn:getMarketActivity/*">
                       <sequence key="MarketActivity"/>
                   </case>
               </switch>
           </inSequence>
           <outSequence>
               <respond/>
           </outSequence>
       </target>
   </proxy>
</definitions>
Excerpt
hiddentrue

The configuration elements

The elements used in the above ESB configuration are explained below.

  • <proxy> - This is the proxy service that should be invoked to execute the configuration.
  • <inSequence> - A message is first received by the proxy service, and then directed to this sequence.
  • <outSequence> - This sequence is triggered after the execution of the <inSequence>.
  • <sequence> - This is an external sequence, which is invoked by the proxy.
  • <send> - This is the Send mediator that routes the message to the endpoint indicated by the address URI.
  • <endpoint> - Defines an endpoint referenced by a name that contains an <address> element with the endpoint address of a particular service. 
  • <sequence> - The Sequence Mediator defines a sequence block, callable by its key (defined in the name attribute). Each sequence block has its own <in> and <out> blocks.
  • <sequence main> - The main sequence that is always run first. 
  • <filter> - A Filter mediator that uses the get-property XPath expression to find the Action field from the SOAP header. The regular expression that is defined in the Regex attribute tries to match the value in the Action field. If successfully matched, it calls the relevant sequence by its key. In line 55, if get-property('Action') returns urn:getQuote, the StockQuote sequence defined in line 39 is called. 

Simulating the example scenario

...

You need to set up the ESB, and the back-end service:

  1. Download the Datatype_1.0.0.zip file, which includes the ESB configuration described above. 
  2. See Setting up the Environment for instructions on setting up the ESB and the back-end service.

    Info

    When you set up the environment, note that you only need to start one instance of the back-end service (Stock Quote Service) to simulate this example.

Executing the sample

Let's send a request to the ESB using the Stock Quote Client application. Find out more about the Stock Quote Client from the ESB documentation.

...