This documentation is for WSO2 Enterprise Integrator version 6.1.1 . View documentation for the latest release.

All docs This doc

Versions Compared

Key

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

...

This sample demonstrates the functionality of dynamic endpoints. Here you will store your endpoints in the registry and refer to them.

...

Code Block
languagehtml/xml
<definitions xmlns="http://ws.apache.org/ns/synapse">
    <registry provider="org.wso2.carbon.mediation.registry.ESBRegistry">
        <parameter name="root">file:repositorysamples/samplesservice-bus/resources/</parameter>
        <parameter name="cachableDuration">15000</parameter>
    </registry>

    <sequence name="main">
        <in>
            <send>
                <endpoint key="endpoint/dynamic_endpt_1.xml"/>
            </send>
        </in>
        <out>
            <send/>
        </out>
    </sequence>
</definitions>

This configuration file  synapse_sample_10.xml is available in the <ESB<EI_HOME>/repository/samples directorysamples/service-bus directory.

To build the sample

  1. Start the ESB Profile with the sample 10 configuration. For instructions on starting a sample ESB configuration, see Starting the ESB with a sample configuration.

    The operation log keeps running until the server starts, which usually takes several seconds. Wait until the server has fully booted up and displays a message similar to "WSO2 Carbon started in n seconds."

  2. Start the Axis2 server. For instructions on starting the Axis2 server, see Starting the Axis2 server.

  3. Deploy the back-end service SimpleStockQuoteService. For instructions on deploying sample back-end services, see Deploying sample back-end services.

  4. Run the following command to start a second Axis2 server on HTTP port 9001 and HTTPS port 9003.

    Code Block
    languagebash
    ./axis2server.sh -http 9001 -https 9003
    

...

  1. Run the following command from the <ESB<EI_HOME>/samples/axis2Client directory.

    Code Block
    languagebash
    ant stockquote -Dtrpurl=http://localhost:8280/
  2. Execute the client immediately again (within 15 seconds of the last execution) using the above command.
  3. Edit the endpoint definition in <ESBin the <EI_HOME>/repositorysamples/samplesservice-bus/resources/endpoint/dynamic_endpt_1.xml xml file by changing the endpoint address to http://localhost:9001/services/SimpleStockQuoteService

Analyzing the output

When you execute the client for the first time, the message is routed to the to SimpleStockQuoteService on the default Axis2 instance on HTTP port 9000.

When you execute the client immediately again,  you will see that the endpoint is cached and reused by the ESB. A similar scenario is explained in Sample 9: Introduction to Dynamic Sequences with the Registry.

When you edit the endpoint definition and execute the client again, you will see that the registry loads the new definition of the endpoint once the cache expires.

Once When the registry loads the new definition of the endpoint,  you will see that the messages are routed to the second sample Axis2 server on HTTP port 9001.

Excerpt
hiddentrue

Example of message mediation in WSO2 ESB.