Versions Compared

Key

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

...

Before digging into implementation details, let's take a look at the relationship between the example scenario and the Routing Slip EIP by comparing their core components.

Routing Slip EIP (Figure 1)Routing Slip Example Scenario (Figure 2)
Request MessageSimple Stock Quote Request
Routing Slip

Header Mediator appends node to SOAP header

Proc A/B/CSequence

Environment setup

  1. Download and install WSO2 ESB from http://wso2.com/products/enterprise-service-bus. For a list of prerequisites and step-by-step installation instructions, refer to Getting Started Installation Guide in the WSO2 ESB documentation.
  2. Start the sample Axis2 server instances. For instructions, refer to the section Setting Up the ESB Samples Setup - Starting Sample Back-End Servicesthe Axis2 server in the WSO2 ESB documentation.

...

Start the ESB server and log into its management console UI (https: //localhost:9443/carbon ). In the management console, navigate to the Main Menu, click Service Bus and then Source View menu and click Source View in the Service Bus section. Next, copy and paste the following configuration, which helps you explore the example scenario, to the source view.

Anchor
step3
step3
   

Code Block
languagehtml/xml
linenumberstrue
 <?xml version="1.0" encoding="UTF-8"?><definitions xmlns="http://ws.apache.org/ns/synapse">
<definitions xmlns="http://ws.apache.org/ns/synapse"> 
    <proxy name="RoutingSlipProxy" transports="http https" startOnLoad="true">
        <target>
            <inSequence>
			
                <!-- Will Attach The Routing Slip -->
                <header xmlns:m1="http://services.samples"
                    name="m1:RoutingSlip"
                    value="Process_A"/>
                <header xmlns:m1="http://services.samples"
                    name="m1:RoutingSlip" value="Process_C"/>
                <log   valuelevel="Process_Cfull"/>
             <log level="full"/>
			   <!-- Will Perform All The Steps Based on The Slip -->
                <iterate xmlns:m0="http://services.samples"
                     preservePayload="true" expression="//m0:RoutingSlip" sequential="true">
                   expression="//m0:RoutingSlip">
 <target>
              <target>          <sequence>
        <sequence>                      <switch xmlns:m2="http://services.samples" source="//m2:RoutingSlip">
                                <case regex="Process_A">
                                    <sequence key="process_a"/>
                                </case>
                                <case regex="Process_B">
                                    <sequence key="process_b"/>
                                </case>
                                <case regex="Process_C">
                                    <sequence key="process_c"/>
                                </case>
                                <default>
                                    <drop/>
                                </default>
                            </switch>
                        </sequence>
                    </target>
                </iterate>
            </inSequence>
            <outSequence>
            <drop    <send/>
            </outSequence>
        </target>
    </proxy>
    <sequence name="processsend_bseq">
        <send>
 <log level="custom">          <property<endpoint name="Processsimple" value="B"/>>
        </log>    </sequence>    <sequence<address nameuri="process_c"http://localhost:9000/services/SimpleStockQuoteService"/>
      <log level="custom">          <property name="Process" value="C"/></endpoint>
        </log>send>
    </sequence>
    <sequence name="process_ac">
        <log level="custom">
            <property name="Process" value="AC"/>
        </log>
        <sequence key="send_seq"/>
    </sequence>
    <sequence name="faultprocess_b">
        <log level="fullcustom">
         <property name="MESSAGE" value="Executing default &#34;fault&#34; sequence"/>
         <property name="ERROR_CODEProcess" expressionvalue="get-property('ERROR_CODE')B"/>
  
      <property name="ERROR_MESSAGE" expression="get-property('ERROR_MESSAGE')"/>
      </log>
     
<drop/>    </sequence>
    <sequence name="sendprocess_seqa">
      <send>          <endpoint name<log level="simplecustom">
            <address<property uriname="http://localhost:9000/services/SimpleStockQuoteService"/>
         </endpoint>
      </send>
   </sequence>
   <sequence name="main">
      <log/>Process" value="A"/>
        <in</>
      <out/>log>
    </sequence>
</definitions>

...

  1. Send a request like the following to the client.

    ant stockquote -Dtrpurl=http://localhost:8280/services/RoutingSlipProxy -Dsymbol=Foofoo
  2. Note that the steps are attached to the message header initially. Thereafter, processing will be decided based on the attached slip. You can observe process A and process C being logged in the ESB management console.
    Axis2 Sever output: 

    samples.services.SimpleStockQuoteService :: Generating quote for : foo

    Client output: 

    Standard :: Stock price = $155.1065862596588


    ESB Console output:

     [EI-Core]  INFO - LogMediator Process = A

    [EI-Core]  INFO - LogMediator Process = C


    You can also allow the message to flow through Process B by indicating a header in the following manner.

    Code Block
    languagehtml/xml
    <header xmlns:m1="http://services.samples"
                        name="m1:RoutingSlip"
                        value="Process_B"/>

    If you add the above header at the beginning, you will notice the message going through Process B as well.


...