This documentation is for WSO2 ESB version 4.0.3. View documentation for the latest release.

Sample 10 Introduction to Dynamic Endpoints with the Registry

Objective: Introduction to dynamic endpoints with the Registry.

<definitions xmlns="http://ws.apache.org/ns/synapse">

    <registry provider="org.wso2.carbon.mediation.registry.ESBRegistry">
        <parameter name="root">file:repository/samples/resources/</parameter>
        <parameter name="cachableDuration">15000</parameter>
    </registry>

    <in>
        <send>
            <endpoint key="endpoint/dynamic_endpt_1.xml"/>
        </send>
    </in>
    <out>
        <send/>
    </out>
</definitions>
Prerequisites
  • Start the Synapse configuration numbered 10: wso2esb-samples -sn 10.
  • Start the Axis2 server and deploy the SimpleStockQuoteService if not already done.
  • Start a second Axis2 server on HTTP port 9001 and HTTPS port 9003 as follows.
./axis2server.sh -http 9001 -https 9003

This example introduces dynamic endpoints, where the definition of an endpoint is stored in the Registry. To follow this example, execute the stock quote client as ant stockquote.. and see that the message is routed to the SimpleStockQuoteService on the default Axis2 instance on HTTP port 9000. Repeat the above example immediately again and notice that the endpoint is cached and reused by ESB - similarly to Sample 9 Introduction to Static and Dynamic Registry Resources and Using XSLT Transformations.

ant stockquote -Dtrpurl=http://localhost:8280/

Now edit the repository/samples/resources/endpoint/dynamic_endpt_1.xml definition and update the address to http://localhost:9001/services/SimpleStockQuoteService. After the cached expires, the Registry loads the new definition of the endpoint and then the messages can be seen being routed to the second sample Axis2 server on HTTP port 9001.