Versions Compared

Key

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

...

Refer to Prerequisites section in ESB Samples Setup page.

Building the Sample

1. Start the ESB with the synapse configuration numbered 267, by running the following command.

  • wso2esb-samples.sh -sn 267
  • wso2esb-samples.bat -sn 267

For more information on starting ESB with different synapse configurations, refer to section Starting Sample ESB Configurations.

2. A message should appear in the command or text Linux console stating the server started successfully.

3. The synapse First, let's take a look at the synapse configuration for the ESB used for this sample. It is provided in <ESB_HOME>/repository/samples/synapse_sample_267.xml as shown below:

Code Block
languagehtml/xml
linenumberstrue
<definitions xmlns="http://ws.apache.org/ns/synapse"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://ws.apache.org/ns/synapse http://synapse.apache.org/ns/2010/04/configuration/synapse_config.xsd">
    <sequence name="myFaultHandler">
        <log level="custom">
            <property name="text" value="** Rollback Transaction**"/>
        </log>
        <transaction action="rollback"/>
        <send/>
    </sequence>
    <sequence name="main" onError="myFaultHandler">
        <in>
            <send>
                <endpoint>
                    <address uri="http://localhost:9000/services/SimpleStockQuoteService"/>
                </endpoint>
            </send>
        </in>
        <out>
            <transaction action="new"/>
            <log level="custom">
                <property name="text" value="** Reporting to the Database esbdb**"/>
            </log>
            <dbreport useTransaction="true" xmlns="http://ws.apache.org/ns/synapse">
                <connection>
                    <pool>
                        <dsName>java:jdbc<dsName>jdbc/XADerbyDS</dsName>
                        <icClass>org.jnp.interfaces.NamingContextFactory</icClass>
     
                  <url>localhost:1099</url>                         <user>synapse</user>
                        <password>synapse</password>
                    </pool>
                </connection>
                <statement>
                    <sql>delete from company where name =?</sql>
                    <parameter expression="//m0:return/m1:symbol/child::text()"
                               xmlns:m0="http://services.samples"
                               xmlns:m1="http://services.samples/xsd"
                               type="VARCHAR"/>
                </statement>
            </dbreport>
            <log level="custom">
                <property name="text" value="** Reporting to the Database esbdb1**"/>
            </log>
            <dbreport useTransaction="true" xmlns="http://ws.apache.org/ns/synapse">
                <connection>
                    <pool>
                        <dsName>java:jdbc<dsName>jdbc/XADerbyDS1</dsName>
                        <icClass>org.jnp.interfaces.NamingContextFactory</icClass>
                        <url>localhost:1099</url>
                        <user>synapse</user>
                        <password>synapse</password>
                    </pool>
                </connection>
                <statement>
                    <sql>INSERT into company values ('IBM','c4',12.0)</sql>
                </statement>
            </dbreport>
            <transaction action="commit"/>
            <send/>
        </out>
    </sequence>
</definitions>

2. Create two database instances to point to sample databases created according to the synapse configuration defined above. Refer the "Sample Setup Guide" to see how you can set up the derby database server.

3. Create two XA data sources in your environment, which the two instances created in step 2 can use. For instructions to create data sources, refer to section Data Sources.

 

1. Start the ESB with the synapse configuration numbered 267, by running the following command.

  • wso2esb-samples.sh -sn 267
  • wso2esb-samples.bat -sn 267

For more information on starting ESB with different synapse configurations, refer to section Starting Sample ESB Configurations.

2. A message should appear in the command or text Linux console stating the server started successfully.

 

4. Deploy the back-end service SimpleStockQuoteService and start the Axis2 server using the instructions given in section Starting Sample Back-End Services.

Info
titleInfor

WSO2 ESB comes with a default JTA transaction manager (Atomikos), which allows you to run distributed transactions without deploying the ESB on an external application server.

5. Define two XA datasources for above two datasources.

6. Create two database instances, this will be used by the two XA data sources.

Info
titleTip

Refer the "Sample Setup Guide" to see how you can set up the derby database server.

Now you have a running ESB instance and a back-end service deployed.

...