Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

Objective: Introduction to dynamic endpoints with the Registry.

Table of Contents

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:

Anchor
synapse_sample_10.xml
synapse_sample_10.xml

Code Block
languagehtml/xmllinenumberstrue
<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>
Prerequisites

...

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.

Code Block
languagebash
./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 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.

Code Block
languagebash
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 - similarly to . Similar scenario is explained in Sample 9: Introduction to Static and Dynamic Registry Resources and Using XSLT Transformations.

Code Block
languagebash
ant stockquote -Dtrpurl=http://localhost:8280/

Now edit the Sequences with the Registry.

4. Now, edit the <ESB_HOME>/repository/samples/resources/endpoint/dynamic_endpt_1.xml definition and update the 's address to http://localhost:9001/services/SimpleStockQuoteService. After the cached expirescache expires (in more than 15 seconds), the Registry loads the new definition of the endpoint and then . Then the messages can be seen being are routed to the second sample Axis2 server on HTTP port 9001.

...