You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@synapse.apache.org by hi...@apache.org on 2010/12/26 11:28:27 UTC
svn commit: r1052855 - in
/synapse/trunk/scratch/hiranya/website/src/site/xdoc/userguide: samples.xml
samples/sample360.xml samples/sample361.xml
Author: hiranya
Date: Sun Dec 26 10:28:26 2010
New Revision: 1052855
URL: http://svn.apache.org/viewvc?rev=1052855&view=rev
Log:
basic DB mediator samples
Modified:
synapse/trunk/scratch/hiranya/website/src/site/xdoc/userguide/samples.xml
synapse/trunk/scratch/hiranya/website/src/site/xdoc/userguide/samples/sample360.xml
synapse/trunk/scratch/hiranya/website/src/site/xdoc/userguide/samples/sample361.xml
Modified: synapse/trunk/scratch/hiranya/website/src/site/xdoc/userguide/samples.xml
URL: http://svn.apache.org/viewvc/synapse/trunk/scratch/hiranya/website/src/site/xdoc/userguide/samples.xml?rev=1052855&r1=1052854&r2=1052855&view=diff
==============================================================================
--- synapse/trunk/scratch/hiranya/website/src/site/xdoc/userguide/samples.xml (original)
+++ synapse/trunk/scratch/hiranya/website/src/site/xdoc/userguide/samples.xml Sun Dec 26 10:28:26 2010
@@ -141,8 +141,8 @@
<h4>Database Mediators (Interacting with Databases)</h4>
<p>
<ul>
- <li><a href="#Sample360">Sample 360: Introduction to dblookup mediator</a></li>
- <li><a href="#Sample361">Sample 361: Introduction to dbreport mediator</a></li>
+ <li><a href="samples/sample360.html">Sample 360: Introduction to dblookup mediator</a></li>
+ <li><a href="samples/sample361.html">Sample 361: Introduction to dbreport mediator</a></li>
<li><a href="#Sample362">Sample 362: Action of dbreport and dblookup mediators together</a></li>
<li><a href="#Sample363">Sample 363: Reusable database connection pools</a></li>
<li><a href="#Sample364">Sample 364: Executing database Stored Procedures</a></li>
Modified: synapse/trunk/scratch/hiranya/website/src/site/xdoc/userguide/samples/sample360.xml
URL: http://svn.apache.org/viewvc/synapse/trunk/scratch/hiranya/website/src/site/xdoc/userguide/samples/sample360.xml?rev=1052855&r1=1052854&r2=1052855&view=diff
==============================================================================
--- synapse/trunk/scratch/hiranya/website/src/site/xdoc/userguide/samples/sample360.xml (original)
+++ synapse/trunk/scratch/hiranya/website/src/site/xdoc/userguide/samples/sample360.xml Sun Dec 26 10:28:26 2010
@@ -23,7 +23,7 @@
<title>Apache Synapse - Sample 360</title>
</properties>
<body>
- <section name="Sample 360: ">
+ <section name="Sample 360: Introduction to DBLookup Mediator">
<div class="xmlConf"><definitions xmlns="http://ws.apache.org/ns/synapse">
<sequence name="myFaultHandler">
@@ -116,13 +116,17 @@
</definitions></div>
<subsection name="Objective">
<p>
-
+ Demonstrating how to perform database lookups during mediation using the dblookup
+ mediator
</p>
</subsection>
<subsection name="Pre-requisites">
<p>
<ul>
<li>
+ Setup a Derby database as described in the database setup guide
+ </li>
+ <li>
Deploy the SimpleStockQuoteService in the sample Axis2 server and start Axis2
</li>
<li>
@@ -136,11 +140,50 @@
</p>
</subsection>
<subsection name="Executing the Client">
- <div class="command">ant stockquote -Daddurl=http://localhost:9000/services/SimpleStockQuoteService -Dtrpurl=http://localhost:8280/</div>
-
- <div class="consoleOutput">Sat Nov 18 21:01:23 IST 2006 SimpleStockQuoteService :: Generating quote for : IBM</div>
-
- <div class="consoleOutput">Standard :: Stock price = $95.26454380258552</div>
+ <p>
+ This sample demonstrates simple database read operations through Synapse. When a
+ message arrives at dblookup mediator, it opens a connection to the database and
+ executes the given SQL query. The SQL query uses '?' character for attributes that
+ will be filled at runtime. The parameters define how to calculate the value of
+ those attributes at runtime. In this sample a dblookup mediator has been used to
+ extract 'id' of the company from the company database using the symbol which is
+ extracted from the SOAP envelope by evaluating an XPath. Then 'id' bases switching
+ will be done by a switch mediator.
+ </p>
+ <p>
+ To try this out, first request a stock quote for the symbol 'IBM' as follows.
+ </p>
+ <div class="command">ant stockquote -Daddurl=http://localhost:9000/services/SimpleStockQuoteService -Dtrpurl=http://localhost:8280/ -Dsymbol=IBM</div>
+ <p>
+ Synapse console will display the following message.
+ </p>
+ <div class="consoleOutput">INFO LogMediator text = ** Looking up from the Database **
+ INFO LogMediator text = Company ID – c1</div>
+ <p>
+ Now request a quote for the symbol 'SUN'.
+ </p>
+ <div class="command">ant stockquote -Daddurl=http://localhost:9000/services/SimpleStockQuoteService -Dtrpurl=http://localhost:8280/ -Dsymbol=SUN</div>
+ <p>
+ Synapse will display the following output.
+ </p>
+ <div class="consoleOutput">INFO LogMediator text = ** Looking up from the Database **
+INFO LogMediator text = Company ID – c2</div>
+ <p>
+ Finally send a stock quote request for the symbol 'MSFT'.
+ </p>
+ <div class="command">ant stockquote -Daddurl=http://localhost:9000/services/SimpleStockQuoteService -Dtrpurl=http://localhost:8280/ -Dsymbol=MSFT</div>
+ <p>
+ In this case Synapse will display the following output.
+ </p>
+ <div class="consoleOutput">INFO LogMediator text = ** Looking up from the Database **
+INFO LogMediator text = Company ID – c2</div>
+ <p>
+ If you send any requests with different symbols, dblookup mediator will return
+ an empty result set, since those symbols are not stored in the Derby database.
+ So as a result Synapse will not be able to determine the company ID, which will
+ result in the following log entry (from the default case in the switch mediator).
+ </p>
+ <div class="consoleOutput">INFO LogMediator text = ** Unrecognized Company ID **</div>
</subsection>
</section>
<p><a href="../samples.html">Back to Catalog</a></p>
Modified: synapse/trunk/scratch/hiranya/website/src/site/xdoc/userguide/samples/sample361.xml
URL: http://svn.apache.org/viewvc/synapse/trunk/scratch/hiranya/website/src/site/xdoc/userguide/samples/sample361.xml?rev=1052855&r1=1052854&r2=1052855&view=diff
==============================================================================
--- synapse/trunk/scratch/hiranya/website/src/site/xdoc/userguide/samples/sample361.xml (original)
+++ synapse/trunk/scratch/hiranya/website/src/site/xdoc/userguide/samples/sample361.xml Sun Dec 26 10:28:26 2010
@@ -23,7 +23,7 @@
<title>Apache Synapse - Sample 361</title>
</properties>
<body>
- <section name="Sample 361: ">
+ <section name="Sample 361: Introduction to DBReport Mediator">
<div class="xmlConf"><definitions xmlns="http://ws.apache.org/ns/synapse">
<sequence name="main">
@@ -65,13 +65,18 @@
</definitions></div>
<subsection name="Objective">
<p>
-
+ <a href="sample360.html">Sample 360</a> shows how to perform database lookups
+ in Synapse. This sample illustrates how to write to a given database from
+ Synapse using the dbreport mediator.
</p>
</subsection>
<subsection name="Pre-requisites">
<p>
<ul>
<li>
+ Setup a Derby database as described in the database setup guide
+ </li>
+ <li>
Deploy the SimpleStockQuoteService in the sample Axis2 server and start Axis2
</li>
<li>
@@ -85,11 +90,30 @@
</p>
</subsection>
<subsection name="Executing the Client">
- <div class="command">ant stockquote -Daddurl=http://localhost:9000/services/SimpleStockQuoteService -Dtrpurl=http://localhost:8280/</div>
-
- <div class="consoleOutput">Sat Nov 18 21:01:23 IST 2006 SimpleStockQuoteService :: Generating quote for : IBM</div>
-
- <div class="consoleOutput">Standard :: Stock price = $95.26454380258552</div>
+ <p>
+ This sample demonstrates how to perform simple database write operations in
+ Synapse. The dbreport mediator writes (i.e. inserts one row) to a table using the
+ details available in messages. It works the same way as the dblookup mediator.
+ In this sample, dbreport mediator is used for updating the stock price of the
+ company using the last quote value which is calculated by evaluating an XPath
+ against the response message. After running this sample, user can check the
+ company table using the Derby client tool. It will show the value inserted by the
+ dbreport mediator.
+ </p>
+ <p>
+ To try this out run the sample client as follows.
+ </p>
+ <div class="command">ant stockquote -Daddurl=http://localhost:9000/services/SimpleStockQuoteService -Dtrpurl=http://localhost:8280/ -Dsymbol=IBM</div>
+ <p>
+ Now execute the following SQL query against the Derby database using the Derby
+ client tool.
+ </p>
+ <div class="command">select price from company where name='IBM';</div>
+ <p>
+ This operation will return the stock quote value returned earlier by Axis2. You
+ can compare the output of the sample Axis2 client with the output of the Derby
+ client tool for confirmation.
+ </p>
</subsection>
</section>
<p><a href="../samples.html">Back to Catalog</a></p>