This sample demonstrates the functionality of dynamic endpoints. Here you will store your endpoints in the registry and refer to them.
<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
To build the sample
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."
Start the Axis2 server. For instructions on starting the Axis2 server, see Starting the Axis2 server.
Deploy the back-end service SimpleStockQuoteService. For instructions on deploying sample back-end services, see Deploying sample back-end services.
Run the following command to start a second Axis2 server on HTTP port 9001 and HTTPS port 9003.
Code Block language bash
./axis2server.sh -http 9001 -https 9003
Run the following command from the
Code Block language bash
ant stockquote -Dtrpurl=http://localhost:8280/
- Execute the client immediately again (within 15 seconds of the last execution) using the above command.
- Edit the endpoint definition in <ESBin the
<EI_HOME>/repositorysamples/samplesservice-bus/resources/endpoint/dynamic_endpt_1.xml xmlfile by changing the endpoint address to
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.
Example of message mediation in WSO2 ESB.