Skip to content

Sequences and Endpoints as Local Registry Entries

This sample demonstrates the functionality of local registry entry definitions, reusable endpoints, and sequences. This example uses a sequence named main that specifies the main mediation rules to be executed. This is equivalent to directly specifying the mediators of the main sequence within the \<definitions\> tag. This sample scenario is a recommended approach for non-trivial configurations.

Synapse configurations

Following are the integration artifacts that we can used to implement this scenario. See the instructions on how to build and run this example.

<proxy name="MainProxy" startOnLoad="true" transports="http https" xmlns="">
            <property name="direction" scope="default" type="STRING" value="incoming"/>
            <sequence key="stockquote"/>
<sequence name="stockquote" trace="disable" xmlns="">
    <!-- log the message using the custom log level. illustrates custom properties for log -->
    <log level="custom">
        <property name="Text" value="Sending quote request"/>
        <property expression="get-property('version')" name="version"/>
        <property expression="get-property('direction')" name="direction"/>
    <!-- send message to real endpoint referenced by key "simple" endpoint definition -->
        <endpoint key="simple"/>
<endpoint name="simple" xmlns="">
    <address uri="http://localhost:9000/services/SimpleStockQuoteService"/>

Build and run

Create the artifacts:

  1. Set up WSO2 Integration Studio.
  2. Create an ESB Solution project
  3. Create the proxy service, sequence, and endpoint with the configurations given above.
  4. Deploy the artifacts in your Micro Integrator.

Set up the back-end service:

  1. Download the stockquote_service.jar.
  2. Open a terminal, navigate to the location of the downloaded service, and run it using the following command:

    java -jar stockquote_service.jar

Send a message to invoke the service and analyze the mediation log on the Micro Integrator's start-up console.

You will see that a sequence named main is executed. Then, for the incoming message flow, the stockquote sequence is called.

DEBUG SequenceMediator - Sequence mediator <main> :: mediate()
DEBUG InMediator - In mediator mediate()
DEBUG SequenceMediator - Sequence mediator <stockquote> :: mediate()

The log mediator dumps a simple text/string property, which is the result of an XPath evaluation that picks up the version key and a second result of an XPath evaluation that picks up a local message property set previously by the property mediator. The get-property() XPath extension function is able to read message properties local to the current message, local or remote registry entries, Axis2 message context properties as well as transport headers. The local entry definition for version defines a simple text/string registry entry, which is visible to all messages that pass through the Micro Integrator.

[HttpServerWorker-1] INFO LogMediator - Text = Sending quote request, version = 0.1, direction = incoming
[HttpServerWorker-1] DEBUG SendMediator - Send mediator :: mediate()
[HttpServerWorker-1] DEBUG AddressEndpoint - Sending To: http://localhost:9000/services/SimpleStockQuoteService