Sample 10: Introduction to Dynamic Endpoints with the Registry
Introduction
This sample demonstrates the functionality of dynamic endpoints, where the definition of an endpoint is stored in the Registry.
Prerequisites
Refer to Prerequisites section in ESB Samples Setup page.
Building the Sample
1. Start the ESB with sample 10 configuration using the instructions given in Starting Sample ESB Configurations.
2. A message should appear in the command or text Linux console stating the server started successfully.
3. The synapse configuration in the ESB used for message mediation in this sample is provided in <ESB_HOME>/repository/samples
/synapse_sample_10.xml
as shown below:
<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> <sequence name="main"> <in> <send> <endpoint key="endpoint/dynamic_endpt_1.xml"/> </send> </in> <out> <send/> </out> </sequence> </definitions>
4. Deploy the back-end service 'SimpleStockQuoteService' and start the Axis2 server using the instructions given in section Starting Sample Back-End Services.
5. Start a second Axis2 server on HTTP port 9001 and HTTPS port 9003 as follows.
./axis2server.sh -http 9001 -https 9003
6. Now you have a running ESB instance and a back-end service deployed. In the next section, we will send a message to the back-end service through the ESB using a sample client.
Executing the Sample
1. The sample client used here is 'Stock Quote Client' which can operate in several modes. For instructions on this sample client and its operation modes, refer to Stock Quote Client. Run the following ant command from <ESB_HOME>/samples/axis2Client
directory.
ant stockquote -Dtrpurl=http://localhost:8280/
2. The message is routed to the SimpleStockQuoteService
on the default Axis2 instance on HTTP port 9000.
3. Repeat the above example immediately again and notice that the endpoint is cached and reused by ESB. Similar scenario is explained in Sample 9: Introduction to Dynamic Sequences with the Registry.
4. Now, edit the <ESB_HOME>/repository/samples/resources/endpoint/dynamic_endpt_1.xml
definition's address to http://localhost:9001/services/SimpleStockQuoteService
. After the cache expires (in more than 15 seconds), the Registry loads the new definition of the endpoint. Then the messages are routed to the second sample Axis2 server on HTTP port 9001.