...
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 Message | Simple Stock Quote Request |
Routing Slip | Header Mediator appends node to SOAP header |
Proc A/B/C | Sequence |
Environment setup
- 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.
- 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.
...
Code Block | ||||
---|---|---|---|---|
| ||||
<?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> <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"> </endpoint> <property name="Process" value="C"/> </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 "fault" 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</> log> <out/> </sequence> </definitions> |
...
- Send a request like the following to the client.
ant stockquote -Dtrpurl=http://localhost:8280/services/RoutingSlipProxy -Dsymbol=foo
- 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 language html/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.
...