Versions Compared

Key

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

...

Info

The Switch and Send mediators of the ESB profile of WSO2 EI simulate the Message Router EIP. The Switch Mediator depicts the Router and observes the content of the message, while the Send Mediator sends the message to a selected recipient.

Each case defined in the Switch mediator is used to decide the routing of the message to the appropriate service. fooOutQueue and barOutQueue act as two separate services.

Image RemovedImage Added

Expand
titleThe Synapse configurations of the artifacts
Tip

When you unzip the ZIP file you download below in Step 6 when simulating the sample scenario, you can find the below configurations in the <UNZIPPED_FILE>/src/main/synapse-config directory. For more information about these artifacts, go to WSO2 EI Documentation.

Localtabgroup
Localtab
titleProxy Service
Code Block
languagexml
<?xml version="1.0" encoding="UTF-8"?>
<proxy name="message-router-proxy" startOnLoad="true" transports="http https"
    xmlns="http://ws.apache.org/ns/synapse">
    <target>
        <inSequence>
            <!-- Will call the message router -->
            <sequence key="MessageRoute"/>
        </inSequence>
        <outSequence>
            <respond/>
        </outSequence>
        <faultSequence/>
    </target>
</proxy>
Localtab
titleSequence
Code Block
languagexml
<?xml version="1.0" encoding="UTF-8"?>
<sequence name="MessageRoute" trace="disable"
    xmlns="http://ws.apache.org/ns/synapse">
    <switch source="//m0:getQuote/m0:request/m0:symbol"
        xmlns:m0="http://services.samples">
        <case regex="foo">
            <send>
                <endpoint>
                    <address uri="http://localhost:9000/services/SimpleStockQuoteService?wsdl"/>
                </endpoint>
            </send>
        </case>
        <case regex="bar">
            <send>
                <endpoint>
                    <address uri="http://localhost:9001/services/SimpleStockQuoteService?wsdl"/>
                </endpoint>
            </send>
        </case>
        <default>
            <property expression="fn:concat('Normal Stock - ', //m0:getQuote/m0:request/m0:symbol)" name="symbol" scope="default" type="STRING"/>
        </default>
    </switch>
</sequence>

...

Gliffy
nameMessage-Router-Diagram
pagePin1112

Analyzing the output

After you execute the above command through the client, observe that the request is transferred to to the foo inventory service. Notice  You view the following processed server log in the Stock Quote Client consolethe Stock Quote Client Console

Standard :: Stock price = $77.86763451813164

Change

Image Added

Also, you view the following log printed in the MyServer1 Axis2 Server Console open in the HTTP port 9000.

Image Added

Now, change the -Dsymbol parameter to bar and run the folloiwng following command:

Code Block
languagepowershell
ant stockquote -Dtrpurl=http://localhost:8280/services/message-router-proxy

...

 -Dsymbol=bar

NowThen, the request goes to to the bar inventory service. Notice You view the following processed server log in the Stock Quote Client console: 

...

the Stock Quote Client Console: 

Image Added

Also, you view the following log printed in the MyServer2 Axis2 Server Console open in the HTTP port 9001.

Image Added