Versions Compared

Key

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

...

Code Block
linenumberstrue
<definitions xmlns="http://ws.apache.org/ns/synapse">
    <registry<localEntry providerkey="org.wso2.carbon.mediation.registry.WSO2RegistryConfigA">
        <parameter name="cachableDuration">15000</parameter><value>foo</value>
        <<description/registry>>
    <taskManager provider="org.wso2.carbon.mediation.ntask.NTaskTaskManager"/></localEntry>
    <localEntry key="ConfigAConfigC">
        <value>foo<<value>WSO2</value>
        <description/>
    </localEntry>
    <localEntry key="ConfigCConfigB">
        <value>WSO2<<value>bar</value>
        <description/>
    </localEntry>
    <proxy xmlns="http://ws.apache.org/ns/synapse" name="DynamicRouterProxy" startOnLoad="true"  <localEntry key="ConfigB">statistics="disable" trace="disable" transports="http,https">
<target>
    <inSequence>
    <value>bar</value>     <log level="full"/>
        <description/><switch source="get-property('To')">
      </localEntry>      <sequence<case nameregex="SendServiceAhttp://localhost:9000.*">
            <filter xmlns:m0="http://services.samples" xpath="get-property('ConfigA') = //m0:getQuote/m0:request/m0:symbol/text()">
            <then>
                <send>
                    <endpoint>
                        <address uri="http://localhost:9000/services/SimpleStockQuoteService"/>
                    </endpoint>
                </send>
            </then>
            <else>
                <log level="custom">
                    <property name="MESSAGE" value="TheRegistry back-end service does not support the requested symbol.Value Doesn't Matched"/>
                </log>
            </else>
        </filter>
    </sequence>case>
    <sequence<case nameregex="SendServiceBhttp://localhost:9001.*">
  
     <filter xmlns:m0="http://services.samples" xpath="get-property('ConfigB') = //m0:getQuote/m0:request/m0:symbol/text()">
 
          <then>
                <send>
       
            <endpoint>
       
                <address uri="http://localhost:9001/services/SimpleStockQuoteService"/>
  
                 </endpoint>
     
          </send>
            </then>
       
    <else>
   
            <log level="custom">
      
             <property name="MESSAGE" value="TheRegistry back-end service does not support the requested symbol."/>
       Value Doesn't Matched"/>
        </log>
       
    </else>
   
    </filter>
   
</sequence>case>
    <sequence name="SendServiceC">
        <case regex="http://localhost:9002.*">
<filter xmlns:m0="http://services.samples" xpath="get-property('ConfigC') = //m0:getQuote/m0:request/m0:symbol/text()">
            <then>
       
        <send>
                    <endpoint>
     
                  <address uri="http://localhost:9002/services/SimpleStockQuoteService"/>
           
        </endpoint>
           
    </send>
        
   </then>
  
         <else>
           
    <log level="custom">

                   <property name="MESSAGE" value="TheRegistry back-end service does not support the requested symbol."/>
         Value Doesn't Matched"/>
      </log>
            </else>
  
     </filter>

   </sequence>
    <sequence name="main">
        <in>
            <log level="full"/>
            <switch source="get-property('To')">
                <case regex="http://localhost:9000.*">
                    <sequence key="SendServiceA"/>
                </case>
                <case regex="http://localhost:9001.*">
                    <sequence key="SendServiceB"/>
                </case>
                <case regex="http://localhost:9002.*">
                    <sequence key="SendServiceC"/>
                </case>
            </switch>
        </in>inSequence>
 <outSequence>
      <out>
            <send/>
       
</out>
 outSequence>
  </sequence>
    <sequence name="fault">
        <!-- Log the message at the full log level with the ERROR_MESSAGE and the ERROR_CODE-->
        <log level="full">
            <property name="MESSAGE" value="Executing default 'fault' sequence"/>
            <property expression="get-property('ERROR_CODE')" name="ERROR_CODE"/>
            <property expression="get-property('ERROR_MESSAGE')" name="ERROR_MESSAGE"/>
        </log>
        <!-- Drops the messages by default if there is a fault -->
        <drop/>
    </sequence>
    <!-- You can add any flat sequences, endpoints, etc.. to this synapse.xml file if you do
    *not* want to keep the artifacts in several files -->
target>
<description/>
</proxy>
</definitions> 

The above configuration helps you explore the sample scenario.

...

You will see that only the first three commands are sent to the back-end services. This is because the symbols passed within those requests are the symbols associated with the particular endpoint service. 

You need to send the corresponding port correctly with the symbol to get the response as follows:

If you send a different request you view the follwoing message in the ESB Console:

[EI-Core]  INFO - LogMediator MESSAGE = Registry Value Doesn't Matched

How the implementation works

...