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 2011/12/22 17:16:05 UTC

svn commit: r1222320 [9/13] - in /synapse/branches/2.1/src: ./ site/ site/resources/ site/resources/css/ site/resources/images/ site/xdoc/ site/xdoc/userguide/ site/xdoc/userguide/samples/ site/xdoc/userguide/samples/setup/

Added: synapse/branches/2.1/src/site/xdoc/userguide/samples/sample362.xml
URL: http://svn.apache.org/viewvc/synapse/branches/2.1/src/site/xdoc/userguide/samples/sample362.xml?rev=1222320&view=auto
==============================================================================
--- synapse/branches/2.1/src/site/xdoc/userguide/samples/sample362.xml (added)
+++ synapse/branches/2.1/src/site/xdoc/userguide/samples/sample362.xml Thu Dec 22 16:16:02 2011
@@ -0,0 +1,143 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!--
+  ~  Licensed to the Apache Software Foundation (ASF) under one
+  ~  or more contributor license agreements.  See the NOTICE file
+  ~  distributed with this work for additional information
+  ~  regarding copyright ownership.  The ASF licenses this file
+  ~  to you under the Apache License, Version 2.0 (the
+  ~  "License"); you may not use this file except in compliance
+  ~  with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~  Unless required by applicable law or agreed to in writing,
+  ~  software distributed under the License is distributed on an
+  ~   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~  KIND, either express or implied.  See the License for the
+  ~  specific language governing permissions and limitations
+  ~  under the License.
+  -->
+
+<document>
+    <properties>
+        <title>Apache Synapse - Sample 362</title>
+    </properties>
+    <body>
+        <section name="Sample 362: Perform Database Lookups and Updates in the Same Mediation Sequence">
+            <div class="xmlConf">&lt;definitions xmlns="http://ws.apache.org/ns/synapse"&gt;
+
+    &lt;sequence name="main"&gt;
+        &lt;in&gt;
+            &lt;send&gt;
+                &lt;endpoint&gt;
+                    &lt;address uri="http://localhost:9000/services/SimpleStockQuoteService"/&gt;
+                &lt;/endpoint&gt;
+            &lt;/send&gt;
+        &lt;/in&gt;
+
+        &lt;out&gt;
+            &lt;log level="custom"&gt;
+                &lt;property name="text" value="** Reporting to the Database **"/&gt;
+            &lt;/log&gt;
+
+            &lt;dbreport&gt;
+                &lt;connection&gt;
+                    &lt;pool&gt;
+                        &lt;driver&gt;org.apache.derby.jdbc.ClientDriver&lt;/driver&gt;
+                        &lt;url&gt;jdbc:derby://localhost:1527/synapsedb;create=false&lt;/url&gt;
+                        &lt;user&gt;synapse&lt;/user&gt;
+                        &lt;password&gt;synapse&lt;/password&gt;
+                    &lt;/pool&gt;
+                &lt;/connection&gt;
+                &lt;statement&gt;
+                    &lt;sql&gt;update company set price=? where name =?&lt;/sql&gt;
+                    &lt;parameter xmlns:m1="http://services.samples/xsd"
+                               xmlns:m0="http://services.samples"
+                               expression="//m0:return/m1:last/child::text()" type="DOUBLE"/&gt;
+                    &lt;parameter xmlns:m1="http://services.samples/xsd"
+                               xmlns:m0="http://services.samples"
+                               expression="//m0:return/m1:symbol/child::text()" type="VARCHAR"/&gt;
+                &lt;/statement&gt;
+            &lt;/dbreport&gt;
+            &lt;log level="custom"&gt;
+                &lt;property name="text" value="** Looking up from the Database **"/&gt;
+            &lt;/log&gt;
+            &lt;dblookup&gt;
+                &lt;connection&gt;
+                    &lt;pool&gt;
+                        &lt;driver&gt;org.apache.derby.jdbc.ClientDriver&lt;/driver&gt;
+                        &lt;url&gt;jdbc:derby://localhost:1527/synapsedb;create=false&lt;/url&gt;
+                        &lt;user&gt;synapse&lt;/user&gt;
+                        &lt;password&gt;synapse&lt;/password&gt;
+                    &lt;/pool&gt;
+                &lt;/connection&gt;
+                &lt;statement&gt;
+                    &lt;sql&gt;select * from company where name =?&lt;/sql&gt;
+                    &lt;parameter xmlns:m1="http://services.samples/xsd"
+                               xmlns:m0="http://services.samples"
+                               expression="//m0:return/m1:symbol/child::text()" type="VARCHAR"/&gt;
+                    &lt;result name="stock_price" column="price"/&gt;
+                &lt;/statement&gt;
+            &lt;/dblookup&gt;
+            &lt;log level="custom"&gt;
+                &lt;property name="text"
+                          expression="fn:concat('Stock price - ',get-property('stock_price'))"/&gt;
+            &lt;/log&gt;
+            &lt;send/&gt;
+        &lt;/out&gt;
+    &lt;/sequence&gt;
+
+&lt;/definitions&gt;</div>
+            <subsection name="Objective">
+                <p>
+                    <a href="sample360.html">Sample 360</a> and <a href="sample361.html">sample 361</a>
+                    shows how to use the dblookup mediator and dbreport mediator separately. This sample
+                    combines them in a single mediation sequence to perform both database lookup and
+                    update operations.
+                </p>
+            </subsection>
+            <subsection name="Pre-requisites">
+                <p>
+                    <ul>
+                        <li>
+                            Setup a Derby database as described in the <a href="setup/db.html">database setup guide</a>
+                        </li>
+                        <li>
+                            Deploy the SimpleStockQuoteService in the sample Axis2 server and start Axis2
+                        </li>
+                        <li>
+                            Start Synapse using the configuration numbered 362 (repository/conf/sample/synapse_sample_362.xml)
+                            <div class="command">
+                                Unix/Linux: sh synapse.sh -sample 362<br/>
+                                Windows: synapse.bat -sample 362
+                            </div>
+                        </li>
+                    </ul>
+                </p>
+            </subsection>
+            <subsection name="Executing the Client">
+                <p>
+                    In this sample, the dbreport mediator works the same way as in
+                    <a href="sample361.html">sample 361</a>. It updates the price for the given company
+                    using the response messages content. Then the dblookup mediator reads the last
+                    updated value from the company database and logs it to the console.
+                </p>
+                <p>
+                    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>
+                    Synapse will update the database using the stock quote value available in the
+                    response sent by Axis2. Then the same value will be retrieved from the database
+                    and logged as follows.
+                </p>
+                <div class="consoleOutput">INFO LogMediator text = ** Reporting to the Database **
+...
+INFO LogMediator text = ** Looking up from the Database **
+...
+INFO LogMediator text = Stock price - 153.47886496064808</div>                
+            </subsection>
+        </section>
+        <p><a href="../samples.html">Back to Catalog</a></p>        
+    </body>
+</document>
\ No newline at end of file

Added: synapse/branches/2.1/src/site/xdoc/userguide/samples/sample363.xml
URL: http://svn.apache.org/viewvc/synapse/branches/2.1/src/site/xdoc/userguide/samples/sample363.xml?rev=1222320&view=auto
==============================================================================
--- synapse/branches/2.1/src/site/xdoc/userguide/samples/sample363.xml (added)
+++ synapse/branches/2.1/src/site/xdoc/userguide/samples/sample363.xml Thu Dec 22 16:16:02 2011
@@ -0,0 +1,205 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!--
+  ~  Licensed to the Apache Software Foundation (ASF) under one
+  ~  or more contributor license agreements.  See the NOTICE file
+  ~  distributed with this work for additional information
+  ~  regarding copyright ownership.  The ASF licenses this file
+  ~  to you under the Apache License, Version 2.0 (the
+  ~  "License"); you may not use this file except in compliance
+  ~  with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~  Unless required by applicable law or agreed to in writing,
+  ~  software distributed under the License is distributed on an
+  ~   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~  KIND, either express or implied.  See the License for the
+  ~  specific language governing permissions and limitations
+  ~  under the License.
+  -->
+
+<document>
+    <properties>
+        <title>Apache Synapse - Sample 363</title>
+    </properties>
+    <body>
+        <section name="Sample 363: Reusable Database Connection Pools">
+            <div class="xmlConf">&lt;definitions xmlns="http://ws.apache.org/ns/synapse"&gt;
+
+    &lt;sequence name="myFaultHandler"&gt;
+        &lt;makefault response="true"&gt;
+            &lt;code xmlns:tns="http://www.w3.org/2003/05/soap-envelope" value="tns:Receiver"/&gt;
+            &lt;reason expression="get-property('ERROR_MESSAGE')"/&gt;
+        &lt;/makefault&gt;
+        &lt;send/&gt;
+        &lt;drop/&gt;
+    &lt;/sequence&gt;
+
+    &lt;sequence name="main" onError="myFaultHandler"&gt;
+        &lt;in&gt;
+            &lt;log level="custom"&gt;
+                &lt;property name="text" value="** Looking up from the Database **"/&gt;
+            &lt;/log&gt;
+            &lt;dblookup&gt;
+                &lt;connection&gt;
+                    &lt;pool&gt;
+                        &lt;dsName&gt;lookupdb&lt;/dsName&gt;
+                    &lt;/pool&gt;
+                &lt;/connection&gt;
+                &lt;statement&gt;
+                    &lt;sql&gt;select * from company where name =?&lt;/sql&gt;
+                    &lt;parameter xmlns:m0="http://services.samples"
+                               expression="//m0:getQuote/m0:request/m0:symbol" type="VARCHAR"/&gt;
+                    &lt;result name="company_id" column="id"/&gt;
+                &lt;/statement&gt;
+            &lt;/dblookup&gt;
+
+            &lt;switch source="get-property('company_id')"&gt;
+                &lt;case regex="c1"&gt;
+                    &lt;log level="custom"&gt;
+                        &lt;property name="text"
+                                  expression="fn:concat('Company ID - ',get-property('company_id'))"/&gt;
+                    &lt;/log&gt;
+                    &lt;send&gt;
+                        &lt;endpoint&gt;
+                            &lt;address uri="http://localhost:9000/services/SimpleStockQuoteService"/&gt;
+                        &lt;/endpoint&gt;
+                    &lt;/send&gt;
+                &lt;/case&gt;
+                &lt;case regex="c2"&gt;
+                    &lt;log level="custom"&gt;
+                        &lt;property name="text"
+                                  expression="fn:concat('Company ID - ',get-property('company_id'))"/&gt;
+                    &lt;/log&gt;
+                    &lt;send&gt;
+                        &lt;endpoint&gt;
+                            &lt;address uri="http://localhost:9000/services/SimpleStockQuoteService"/&gt;
+                        &lt;/endpoint&gt;
+                    &lt;/send&gt;
+                &lt;/case&gt;
+                &lt;case regex="c3"&gt;
+                    &lt;log level="custom"&gt;
+                        &lt;property name="text"
+                                  expression="fn:concat('Company ID - ',get-property('company_id'))"/&gt;
+                    &lt;/log&gt;
+                    &lt;send&gt;
+                        &lt;endpoint&gt;
+                            &lt;address uri="http://localhost:9000/services/SimpleStockQuoteService"/&gt;
+                        &lt;/endpoint&gt;
+                    &lt;/send&gt;
+                &lt;/case&gt;
+                &lt;default&gt;
+                    &lt;log level="custom"&gt;
+                        &lt;property name="text" value="** Unrecognized Company ID **"/&gt;
+                    &lt;/log&gt;
+                    &lt;makefault response="true"&gt;
+                        &lt;code xmlns:tns="http://www.w3.org/2003/05/soap-envelope"
+                              value="tns:Receiver"/&gt;
+                        &lt;reason value="** Unrecognized Company ID **"/&gt;
+                    &lt;/makefault&gt;
+                    &lt;send/&gt;
+                    &lt;drop/&gt;
+                &lt;/default&gt;
+            &lt;/switch&gt;
+            &lt;drop/&gt;
+        &lt;/in&gt;
+
+        &lt;out&gt;
+            &lt;log level="custom"&gt;
+                &lt;property name="text" value="** Reporting to the Database **"/&gt;
+            &lt;/log&gt;
+            &lt;dbreport&gt;
+                &lt;connection&gt;
+                    &lt;pool&gt;
+                        &lt;dsName&gt;reportdb&lt;/dsName&gt;
+                    &lt;/pool&gt;
+                &lt;/connection&gt;
+                &lt;statement&gt;
+                    &lt;sql&gt;update company set price=? where name =?&lt;/sql&gt;
+                    &lt;parameter xmlns:m0="http://services.samples"
+                               xmlns:m1="http://services.samples/xsd"
+                               expression="//m0:return/m1:last/child::text()" type="DOUBLE"/&gt;
+                    &lt;parameter xmlns:m0="http://services.samples"
+                               xmlns:m1="http://services.samples/xsd"
+                               expression="//m0:return/m1:symbol/child::text()" type="VARCHAR"/&gt;
+                &lt;/statement&gt;
+            &lt;/dbreport&gt;
+            &lt;log level="custom"&gt;
+                &lt;property name="text" value="** Looking up from the Database **"/&gt;
+            &lt;/log&gt;
+            &lt;dblookup&gt;
+                &lt;connection&gt;
+                    &lt;pool&gt;
+                        &lt;dsName&gt;reportdb&lt;/dsName&gt;
+                    &lt;/pool&gt;
+                &lt;/connection&gt;
+                &lt;statement&gt;
+                    &lt;sql&gt;select * from company where name =?&lt;/sql&gt;
+                    &lt;parameter xmlns:m0="http://services.samples"
+                               xmlns:m1="http://services.samples/xsd"
+                               expression="//m0:return/m1:symbol/child::text()" type="VARCHAR"/&gt;
+                    &lt;result name="stock_price" column="price"/&gt;
+                &lt;/statement&gt;
+            &lt;/dblookup&gt;
+            &lt;log level="custom"&gt;
+                &lt;property name="text"
+                          expression="fn:concat('Stock price - ',get-property('stock_price'))"/&gt;
+            &lt;/log&gt;
+            &lt;send/&gt;
+
+        &lt;/out&gt;
+
+    &lt;/sequence&gt;
+
+&lt;/definitions&gt;</div>
+            <subsection name="Objective">
+                <p>
+                    Demonstrate how to setup reusable connection pools for the dblookup and dbreport
+                    mediators
+                </p>
+            </subsection>
+            <subsection name="Pre-requisites">
+                <p>
+                    <ul>
+                        <li>
+                            Setup a Derby database and the Synapse data sources as described in the
+                            <a href="setup/db.html">database setup guide</a>
+                        </li>
+                        <li>
+                            Deploy the SimpleStockQuoteService in the sample Axis2 server and start Axis2
+                        </li>
+                        <li>
+                            Start Synapse using the configuration numbered 363 (repository/conf/sample/synapse_sample_363.xml)
+                            <div class="command">
+                                Unix/Linux: sh synapse.sh -sample 363<br/>
+                                Windows: synapse.bat -sample 363
+                            </div>
+                        </li>
+                    </ul>
+                </p>
+            </subsection>
+            <subsection name="Executing the Client">
+                <p>
+                    This sample employs two instances of the dblookup mediator and a single instance
+                    of the dbreport mediator. The two dblookup mediators are sharing the same database
+                    connection pool named 'lookupdb'. The dbreport mediator makes use of a different
+                    connection pool named 'dbreport'. Synapse uses Apache DBCP to create and manage
+                    the corresponding data sources and connection pools.
+                </p>
+                <p>
+                    Run this sample by invoking the client as follows.
+                </p>
+                <div class="command">ant stockquote -Daddurl=http://localhost:9000/services/SimpleStockQuoteService -Dtrpurl=http://localhost:8280/ -Dsymbol=IBM</div>
+                <p>
+                    Synapse will log the following output as it reads from and writes to the database.
+                </p>
+                <div class="consoleOutput">INFO LogMediator text = ** Looking up from the Database ** ...
+INFO LogMediator text = Company ID - c1 ...
+INFO LogMediator text = ** Reporting to the Database ** ...
+INFO LogMediator text = ** Looking up from the Database ** ...
+INFO LogMediator text = Stock price - 183.3635460215262</div>
+            </subsection>
+        </section>
+        <p><a href="../samples.html">Back to Catalog</a></p>        
+    </body>
+</document>
\ No newline at end of file

Added: synapse/branches/2.1/src/site/xdoc/userguide/samples/sample364.xml
URL: http://svn.apache.org/viewvc/synapse/branches/2.1/src/site/xdoc/userguide/samples/sample364.xml?rev=1222320&view=auto
==============================================================================
--- synapse/branches/2.1/src/site/xdoc/userguide/samples/sample364.xml (added)
+++ synapse/branches/2.1/src/site/xdoc/userguide/samples/sample364.xml Thu Dec 22 16:16:02 2011
@@ -0,0 +1,142 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!--
+  ~  Licensed to the Apache Software Foundation (ASF) under one
+  ~  or more contributor license agreements.  See the NOTICE file
+  ~  distributed with this work for additional information
+  ~  regarding copyright ownership.  The ASF licenses this file
+  ~  to you under the Apache License, Version 2.0 (the
+  ~  "License"); you may not use this file except in compliance
+  ~  with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~  Unless required by applicable law or agreed to in writing,
+  ~  software distributed under the License is distributed on an
+  ~   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~  KIND, either express or implied.  See the License for the
+  ~  specific language governing permissions and limitations
+  ~  under the License.
+  -->
+
+<document>
+    <properties>
+        <title>Apache Synapse - Sample 364</title>
+    </properties>
+    <body>
+        <section name="Sample 364: Executing Database Stored Procedures">
+            <div class="xmlConf">&lt;definitions xmlns="http://ws.apache.org/ns/synapse"&gt;
+
+    &lt;sequence name="main"&gt;
+        &lt;in&gt;
+            &lt;send&gt;
+                &lt;endpoint&gt;
+                    &lt;address uri="http://localhost:9000/services/SimpleStockQuoteService"/&gt;
+                &lt;/endpoint&gt;
+            &lt;/send&gt;
+        &lt;/in&gt;
+
+        &lt;out&gt;
+            &lt;log level="custom"&gt;
+                &lt;property name="text" value="** Reporting to the Database **"/&gt;
+            &lt;/log&gt;
+
+            &lt;dbreport&gt;
+                &lt;connection&gt;
+                    &lt;pool&gt;
+                        &lt;driver&gt;com.mysql.jdbc.Driver&lt;/driver&gt;
+                        &lt;url&gt;jdbc:mysql://localhost:3306/synapsedb&lt;/url&gt;
+                        &lt;user&gt;user&lt;/user&gt;
+                        &lt;password&gt;password&lt;/password&gt;
+                    &lt;/pool&gt;
+                &lt;/connection&gt;
+                &lt;statement&gt;
+                    &lt;sql&gt;call updateCompany(?,?)&lt;/sql&gt;
+                    &lt;parameter xmlns:m0="http://services.samples"
+                               xmlns:m1="http://services.samples/xsd"
+                               expression="//m0:return/m1:last/child::text()" type="DOUBLE"/&gt;
+                    &lt;parameter xmlns:m0="http://services.samples"
+                               xmlns:m1="http://services.samples/xsd"
+                               expression="//m0:return/m1:symbol/child::text()" type="VARCHAR"/&gt;
+                &lt;/statement&gt;
+            &lt;/dbreport&gt;
+            &lt;log level="custom"&gt;
+                &lt;property name="text" value="** Looking up from the Database **"/&gt;
+            &lt;/log&gt;
+            &lt;dblookup&gt;
+                &lt;connection&gt;
+                    &lt;pool&gt;
+                        &lt;driver&gt;com.mysql.jdbc.Driver&lt;/driver&gt;
+                        &lt;url&gt;jdbc:mysql://localhost:3306/synapsedb&lt;/url&gt;
+                        &lt;user&gt;user&lt;/user&gt;
+                        &lt;password&gt;password&lt;/password&gt;
+                    &lt;/pool&gt;
+                &lt;/connection&gt;
+                &lt;statement&gt;
+                    &lt;sql&gt;call getCompany(?)&lt;/sql&gt;
+                    &lt;parameter xmlns:m0="http://services.samples"
+                               xmlns:m1="http://services.samples/xsd"
+                               expression="//m0:return/m1:symbol/child::text()" type="VARCHAR"/&gt;
+                    &lt;result name="stock_prize" column="price"/&gt;
+                &lt;/statement&gt;
+            &lt;/dblookup&gt;
+            &lt;log level="custom"&gt;
+                &lt;property name="text"
+                          expression="fn:concat('Stock Prize - ',get-property('stock_prize'))"/&gt;
+            &lt;/log&gt;
+            &lt;send/&gt;
+        &lt;/out&gt;
+    &lt;/sequence&gt;
+
+&lt;/definitions&gt;</div>
+            <subsection name="Objective">
+                <p>
+                    Demonstrate how to invoke a database stored procedure from Synapse
+                </p>
+            </subsection>
+            <subsection name="Pre-requisites">
+                <p>
+                    <ul>
+                        <li>
+                            Setup a MySQL database as described in the <a href="setup/db.html#mysql">database setup guide</a>
+                        </li>
+                        <li>
+                            Deploy the SimpleStockQuoteService in the sample Axis2 server and start Axis2
+                        </li>
+                        <li>
+                            Open the repository/conf/sample/synapse_sample_364.xml file and change the
+                            database username, password credentials accordingly
+                        </li>
+                        <li>
+                            Start Synapse using the configuration numbered 364 (repository/conf/sample/synapse_sample_364.xml)
+                            <div class="command">
+                                Unix/Linux: sh synapse.sh -sample 364<br/>
+                                Windows: synapse.bat -sample 364
+                            </div>
+                        </li>
+                    </ul>
+                </p>
+            </subsection>
+            <subsection name="Executing the Client">
+                <p>
+                    This scenario is very similar to <a href="sample363.html">sample 363</a>, but makes
+                    use of stored procedures to lookup and update the database instead of simple
+                    SQL queries. Note that we are still using the dblookup and dbreport mediators
+                    to access the database but the statements are simply calling a stored procedure in
+                    MySQL (the syntax to call a stored procedue is database engine specific).
+                </p>
+                <p>
+                    To try this sample out, invoke 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>
+                    Synapse will invoke the two stored procedures as the response is mediated back
+                    to the client. You will see the following output on the Synapse console.
+                </p>
+                <div class="consoleOutput">INFO LogMediator text = ** Looking up from the Database ** ...
+INFO LogMediator text = Company ID - c1 ...
+INFO LogMediator text = Stock price - 183.3635460215262</div>
+            </subsection>
+        </section>
+        <p><a href="../samples.html">Back to Catalog</a></p>        
+    </body>
+</document>
\ No newline at end of file

Added: synapse/branches/2.1/src/site/xdoc/userguide/samples/sample370.xml
URL: http://svn.apache.org/viewvc/synapse/branches/2.1/src/site/xdoc/userguide/samples/sample370.xml?rev=1222320&view=auto
==============================================================================
--- synapse/branches/2.1/src/site/xdoc/userguide/samples/sample370.xml (added)
+++ synapse/branches/2.1/src/site/xdoc/userguide/samples/sample370.xml Thu Dec 22 16:16:02 2011
@@ -0,0 +1,116 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!--
+  ~  Licensed to the Apache Software Foundation (ASF) under one
+  ~  or more contributor license agreements.  See the NOTICE file
+  ~  distributed with this work for additional information
+  ~  regarding copyright ownership.  The ASF licenses this file
+  ~  to you under the Apache License, Version 2.0 (the
+  ~  "License"); you may not use this file except in compliance
+  ~  with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~  Unless required by applicable law or agreed to in writing,
+  ~  software distributed under the License is distributed on an
+  ~   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~  KIND, either express or implied.  See the License for the
+  ~  specific language governing permissions and limitations
+  ~  under the License.
+  -->
+
+<document>
+    <properties>
+        <title>Apache Synapse - Sample 370</title>
+    </properties>
+    <body>
+        <section name="Sample 370: Introduction to Throttle Mediator and Concurrency Throttling">
+            <div class="xmlConf">&lt;definitions xmlns="http://ws.apache.org/ns/synapse"&gt;
+
+    &lt;sequence name="main"&gt;
+        &lt;in&gt;
+            &lt;throttle id="A"&gt;
+                &lt;policy&gt;
+                    &lt;!-- define throttle policy --&gt;
+                    &lt;wsp:Policy xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"
+                                xmlns:throttle="http://www.wso2.org/products/wso2commons/throttle"&gt;
+                        &lt;throttle:ThrottleAssertion&gt;
+                            &lt;throttle:MaximumConcurrentAccess&gt;10&lt;/throttle:MaximumConcurrentAccess&gt;
+                        &lt;/throttle:ThrottleAssertion&gt;
+                    &lt;/wsp:Policy&gt;
+                &lt;/policy&gt;
+                &lt;onAccept&gt;
+                    &lt;log level="custom"&gt;
+                        &lt;property name="text" value="**Access Accept**"/&gt;
+                    &lt;/log&gt;
+                    &lt;send&gt;
+                        &lt;endpoint&gt;
+                            &lt;address uri="http://localhost:9000/services/SimpleStockQuoteService"/&gt;
+                        &lt;/endpoint&gt;
+                    &lt;/send&gt;
+                &lt;/onAccept&gt;
+                &lt;onReject&gt;
+                    &lt;log level="custom"&gt;
+                        &lt;property name="text" value="**Access Denied**"/&gt;
+                    &lt;/log&gt;
+                    &lt;makefault response="true"&gt;
+                        &lt;code xmlns:tns="http://www.w3.org/2003/05/soap-envelope"
+                              value="tns:Receiver"/&gt;
+                        &lt;reason value="**Access Denied**"/&gt;
+                    &lt;/makefault&gt;
+                    &lt;send/&gt;
+                    &lt;drop/&gt;
+                &lt;/onReject&gt;
+            &lt;/throttle&gt;
+        &lt;/in&gt;
+        &lt;out&gt;
+            &lt;throttle id="A"/&gt;
+            &lt;send/&gt;
+        &lt;/out&gt;
+    &lt;/sequence&gt;
+
+&lt;/definitions&gt;</div>
+            <subsection name="Objective">
+                <p>
+                    Showcase the ability of Synapse to throttle incoming requests based on the
+                    concurrency level
+                </p>
+            </subsection>
+            <subsection name="Pre-requisites">
+                <p>
+                    <ul>
+                        <li>
+                            Deploy the SimpleStockQuoteService in the sample Axis2 server and start Axis2
+                        </li>
+                        <li>
+                            Start Synapse using the configuration numbered 370 (repository/conf/sample/synapse_sample_370.xml)
+                            <div class="command">
+                                Unix/Linux: sh synapse.sh -sample 370<br/>
+                                Windows: synapse.bat -sample 370
+                            </div>
+                        </li>
+                    </ul>
+                </p>
+            </subsection>
+            <subsection name="Executing the Client">
+                <p>
+                    Above configuration specifies a throttle mediator inside the in mediator.
+                    Therefore, all request messages directed to the main sequence will be subjected
+                    to throttling. Throttle mediator has 'policy', 'onAccept' and 'onReject' tags at
+                    top level. The 'policy' tag specifies the throttling policy for throttling messages.
+                    This sample policy only contains a component called 'MaximumConcurrentAccess'.
+                    This indicates the maximum number of concurrent requests that can pass through
+                    Synapse on a single unit of time. To test concurrency throttling, it is required
+                    to send concurrent requests to Synapse. With this configuration if Synapse receives
+                    20 requests concurrently from clients, then approximately half of those will succeed
+                    while the others being throttled. The client command to try this is as follows.
+                </p>
+                <div class="command">ant stockquote -Dsymbol=IBM -Dmode=quote -Daddurl=http://localhost:8280/</div>
+                <p>
+                    It's not that easy to try this sample out using the sample Axis2 client. For
+                    better results, consider using a load testing tool like Apache Bench or Java Bench.
+                </p>
+            </subsection>
+        </section>
+        <p><a href="../samples.html">Back to Catalog</a></p>        
+    </body>
+</document>
\ No newline at end of file

Added: synapse/branches/2.1/src/site/xdoc/userguide/samples/sample371.xml
URL: http://svn.apache.org/viewvc/synapse/branches/2.1/src/site/xdoc/userguide/samples/sample371.xml?rev=1222320&view=auto
==============================================================================
--- synapse/branches/2.1/src/site/xdoc/userguide/samples/sample371.xml (added)
+++ synapse/branches/2.1/src/site/xdoc/userguide/samples/sample371.xml Thu Dec 22 16:16:02 2011
@@ -0,0 +1,176 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!--
+  ~  Licensed to the Apache Software Foundation (ASF) under one
+  ~  or more contributor license agreements.  See the NOTICE file
+  ~  distributed with this work for additional information
+  ~  regarding copyright ownership.  The ASF licenses this file
+  ~  to you under the Apache License, Version 2.0 (the
+  ~  "License"); you may not use this file except in compliance
+  ~  with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~  Unless required by applicable law or agreed to in writing,
+  ~  software distributed under the License is distributed on an
+  ~   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~  KIND, either express or implied.  See the License for the
+  ~  specific language governing permissions and limitations
+  ~  under the License.
+  -->
+
+<document>
+    <properties>
+        <title>Apache Synapse - Sample 371</title>
+    </properties>
+    <body>
+        <section name="Sample 371: Restricting Requests Based on Policies">
+            <div class="xmlConf">&lt;definitions xmlns="http://ws.apache.org/ns/synapse"&gt;
+
+    &lt;sequence name="main"&gt;
+        &lt;in&gt;
+            &lt;throttle id="A"&gt;
+                &lt;policy&gt;
+                    &lt;!-- define throttle policy --&gt;
+                    &lt;wsp:Policy xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"
+                                xmlns:throttle="http://www.wso2.org/products/wso2commons/throttle"&gt;
+                        &lt;throttle:ThrottleAssertion&gt;
+                            &lt;wsp:All&gt;
+                                &lt;throttle:ID throttle:type="IP"&gt;other&lt;/throttle:ID&gt;
+                                &lt;wsp:ExactlyOne&gt;
+                                    &lt;wsp:All&gt;
+                                        &lt;throttle:MaximumCount&gt;4&lt;/throttle:MaximumCount&gt;
+                                        &lt;throttle:UnitTime&gt;800000&lt;/throttle:UnitTime&gt;
+                                        &lt;throttle:ProhibitTimePeriod wsp:Optional="true"&gt;10000
+                                        &lt;/throttle:ProhibitTimePeriod&gt;
+                                    &lt;/wsp:All&gt;
+                                    &lt;throttle:IsAllow&gt;true&lt;/throttle:IsAllow&gt;
+                                &lt;/wsp:ExactlyOne&gt;
+                            &lt;/wsp:All&gt;
+                            &lt;wsp:All&gt;
+                                &lt;throttle:ID throttle:type="IP"&gt;192.168.8.200-192.168.8.222
+                                &lt;/throttle:ID&gt;
+                                &lt;wsp:ExactlyOne&gt;
+                                    &lt;wsp:All&gt;
+                                        &lt;throttle:MaximumCount&gt;8&lt;/throttle:MaximumCount&gt;
+                                        &lt;throttle:UnitTime&gt;800000&lt;/throttle:UnitTime&gt;
+                                        &lt;throttle:ProhibitTimePeriod wsp:Optional="true"&gt;10
+                                        &lt;/throttle:ProhibitTimePeriod&gt;
+                                    &lt;/wsp:All&gt;
+                                    &lt;throttle:IsAllow&gt;true&lt;/throttle:IsAllow&gt;
+                                &lt;/wsp:ExactlyOne&gt;
+                            &lt;/wsp:All&gt;
+                            &lt;wsp:All&gt;
+                                &lt;throttle:ID throttle:type="IP"&gt;192.168.8.201&lt;/throttle:ID&gt;
+                                &lt;wsp:ExactlyOne&gt;
+                                    &lt;wsp:All&gt;
+                                        &lt;throttle:MaximumCount&gt;200&lt;/throttle:MaximumCount&gt;
+                                        &lt;throttle:UnitTime&gt;600000&lt;/throttle:UnitTime&gt;
+                                        &lt;throttle:ProhibitTimePeriod wsp:Optional="true"/&gt;
+                                    &lt;/wsp:All&gt;
+                                    &lt;throttle:IsAllow&gt;true&lt;/throttle:IsAllow&gt;
+                                &lt;/wsp:ExactlyOne&gt;
+                            &lt;/wsp:All&gt;
+                            &lt;wsp:All&gt;
+                                &lt;throttle:ID throttle:type="IP"&gt;192.168.8.198&lt;/throttle:ID&gt;
+                                &lt;wsp:ExactlyOne&gt;
+                                    &lt;wsp:All&gt;
+                                        &lt;throttle:MaximumCount&gt;50&lt;/throttle:MaximumCount&gt;
+                                        &lt;throttle:UnitTime&gt;500000&lt;/throttle:UnitTime&gt;
+                                        &lt;throttle:ProhibitTimePeriod wsp:Optional="true"/&gt;
+                                    &lt;/wsp:All&gt;
+                                    &lt;throttle:IsAllow&gt;true&lt;/throttle:IsAllow&gt;
+                                &lt;/wsp:ExactlyOne&gt;
+                            &lt;/wsp:All&gt;
+                        &lt;/throttle:ThrottleAssertion&gt;
+                    &lt;/wsp:Policy&gt;
+                &lt;/policy&gt;
+                &lt;onAccept&gt;
+                    &lt;log level="custom"&gt;
+                        &lt;property name="text" value="**Access Accept**"/&gt;
+                    &lt;/log&gt;
+                    &lt;send&gt;
+                        &lt;endpoint&gt;
+                            &lt;address uri="http://localhost:9000/services/SimpleStockQuoteService"/&gt;
+                        &lt;/endpoint&gt;
+                    &lt;/send&gt;
+                &lt;/onAccept&gt;
+                &lt;onReject&gt;
+                    &lt;log level="custom"&gt;
+                        &lt;property name="text" value="**Access Denied**"/&gt;
+                    &lt;/log&gt;
+                    &lt;makefault response="true"&gt;
+                        &lt;code xmlns:tns="http://www.w3.org/2003/05/soap-envelope"
+                              value="tns:Receiver"/&gt;
+                        &lt;reason value="**Access Denied**"/&gt;
+                    &lt;/makefault&gt;
+                    &lt;send/&gt;
+                    &lt;drop/&gt;
+                &lt;/onReject&gt;
+            &lt;/throttle&gt;
+        &lt;/in&gt;
+        &lt;out&gt;
+            &lt;throttle id="A"/&gt;
+            &lt;send/&gt;
+        &lt;/out&gt;
+    &lt;/sequence&gt;
+
+&lt;/definitions&gt;</div>
+            <subsection name="Objective">
+                <p>
+                    Demonstrate how to throttle incoming requests based on complex policies
+                </p>
+            </subsection>
+            <subsection name="Pre-requisites">
+                <p>
+                    <ul>
+                        <li>
+                            Deploy the SimpleStockQuoteService in the sample Axis2 server and start Axis2
+                        </li>
+                        <li>
+                            Start Synapse using the configuration numbered 371 (repository/conf/sample/synapse_sample_371.xml)
+                            <div class="command">
+                                Unix/Linux: sh synapse.sh -sample 371<br/>
+                                Windows: synapse.bat -sample 371
+                            </div>
+                        </li>
+                    </ul>
+                </p>
+            </subsection>
+            <subsection name="Executing the Client">
+                <p>
+                    Above configuration specifies a throttle mediator inside the in mediator.
+                    Therefore, all request messages directed to the main sequence will be subjected
+                    to throttling. Throttle mediator has policy, onAccept and onReject tags at the
+                    top level. Policy tag specifies the throttling policy against which all messages
+                    will be evaluated. It contains some IP address ranges and the maximum number of
+                    messages to be allowed for those ranges within a time period given in 'UnitTime'
+                    tag. 'ProhibitTimePeriod' tag specifies the time period to prohibit further
+                    requests after the received request count exceeds the specified time. Now run the
+                    client 5 times repetitively using the following command to see how throttling works.
+                </p>
+                <div class="command">ant stockquote -Dsymbol=IBM -Dmode=quote -Daddurl=http://localhost:8280/</div>
+                <p>
+                    For the first four requests you will get the quote prices for IBM as follows.
+                </p>
+                <div class="consoleOutput">[java] Standard :: Stock price = $177.20143371883802</div>
+                <p>
+                    Fifth request will not be sent to the Axis2 server and the client will receive
+                    the following fault.
+                </p>
+                <div class="consoleOutput">[java] org.apache.axis2.AxisFault: **Access Denied**</div>
+                <p>
+                    Maximum number of requests within 800000 milliseconds is specified as 4 for any
+                    server (including localhost) other than the explicitly specified ones. Therefore,
+                    our fifth request is denied by the throttle mediator. You can verify this by looking
+                    at the Synapse console.
+                </p>
+                <div class="consoleOutput">[HttpServerWorker-1] INFO  LogMediator - text = **Access Accept**
+[HttpServerWorker-2] INFO  LogMediator - text = **Access Accept**
+[HttpServerWorker-3] INFO  LogMediator - text = **Access Accept**
+[HttpServerWorker-4] INFO  LogMediator - text = **Access Accept**
+[HttpServerWorker-5] INFO  LogMediator - text = **Access Denied**</div>
+            </subsection>
+        </section>
+        <p><a href="../samples.html">Back to Catalog</a></p>        
+    </body>
+</document>
\ No newline at end of file

Added: synapse/branches/2.1/src/site/xdoc/userguide/samples/sample372.xml
URL: http://svn.apache.org/viewvc/synapse/branches/2.1/src/site/xdoc/userguide/samples/sample372.xml?rev=1222320&view=auto
==============================================================================
--- synapse/branches/2.1/src/site/xdoc/userguide/samples/sample372.xml (added)
+++ synapse/branches/2.1/src/site/xdoc/userguide/samples/sample372.xml Thu Dec 22 16:16:02 2011
@@ -0,0 +1,119 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!--
+  ~  Licensed to the Apache Software Foundation (ASF) under one
+  ~  or more contributor license agreements.  See the NOTICE file
+  ~  distributed with this work for additional information
+  ~  regarding copyright ownership.  The ASF licenses this file
+  ~  to you under the Apache License, Version 2.0 (the
+  ~  "License"); you may not use this file except in compliance
+  ~  with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~  Unless required by applicable law or agreed to in writing,
+  ~  software distributed under the License is distributed on an
+  ~   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~  KIND, either express or implied.  See the License for the
+  ~  specific language governing permissions and limitations
+  ~  under the License.
+  -->
+
+<document>
+    <properties>
+        <title>Apache Synapse - Sample 372</title>
+    </properties>
+    <body>
+        <section name="Sample 372: Use of Concurrency Throttling and Request Rate Based Throttling">
+            <div class="xmlConf">&lt;definitions xmlns="http://ws.apache.org/ns/synapse"&gt;
+
+    &lt;registry provider="org.apache.synapse.registry.url.SimpleURLRegistry"&gt;
+        &lt;!-- the root property of the simple URL registry helps resolve a resource URL as root + key --&gt;
+        &lt;parameter name="root"&gt;file:repository/&lt;/parameter&gt;
+        &lt;!-- all resources loaded from the URL registry would be cached for this number of milli seconds --&gt;
+        &lt;parameter name="cachableDuration"&gt;150000&lt;/parameter&gt;
+    &lt;/registry&gt;
+
+    &lt;sequence name="onAcceptSequence"&gt;
+        &lt;log level="custom"&gt;
+            &lt;property name="text" value="**Access Accept**"/&gt;
+        &lt;/log&gt;
+        &lt;send&gt;
+            &lt;endpoint&gt;
+                &lt;address uri="http://localhost:9000/services/SimpleStockQuoteService"/&gt;
+            &lt;/endpoint&gt;
+        &lt;/send&gt;
+    &lt;/sequence&gt;
+
+    &lt;sequence name="onRejectSequence" trace="enable"&gt;
+        &lt;log level="custom"&gt;
+            &lt;property name="text" value="**Access Denied**"/&gt;
+        &lt;/log&gt;
+        &lt;makefault response="true"&gt;
+            &lt;code xmlns:tns="http://www.w3.org/2003/05/soap-envelope" value="tns:Receiver"/&gt;
+            &lt;reason value="**Access Denied**"/&gt;
+        &lt;/makefault&gt;
+        &lt;send/&gt;
+        &lt;drop/&gt;
+    &lt;/sequence&gt;
+
+    &lt;proxy name="StockQuoteProxy"&gt;
+        &lt;target&gt;
+            &lt;inSequence&gt;
+                &lt;throttle onReject="onRejectSequence" onAccept="onAcceptSequence" id="A"&gt;
+                    &lt;policy key="conf/sample/resources/policy/throttle_policy.xml"/&gt;
+                &lt;/throttle&gt;
+            &lt;/inSequence&gt;
+            &lt;outSequence&gt;
+                &lt;throttle id="A"/&gt;
+                &lt;send/&gt;
+            &lt;/outSequence&gt;
+        &lt;/target&gt;
+        &lt;publishWSDL uri="file:repository/conf/sample/resources/proxy/sample_proxy_1.wsdl"/&gt;
+    &lt;/proxy&gt;
+
+&lt;/definitions&gt;</div>
+            <subsection name="Objective">
+                <p>
+                    Showcase how to use the concurrency throttling in conjunction with request rate
+                    throttling
+                </p>
+            </subsection>
+            <subsection name="Pre-requisites">
+                <p>
+                    <ul>
+                        <li>
+                            Deploy the SimpleStockQuoteService in the sample Axis2 server and start Axis2
+                        </li>
+                        <li>
+                            Start Synapse using the configuration numbered 372 (repository/conf/sample/synapse_sample_372.xml)
+                            <div class="command">
+                                Unix/Linux: sh synapse.sh -sample 372<br/>
+                                Windows: synapse.bat -sample 372
+                            </div>
+                        </li>
+                    </ul>
+                </p>
+            </subsection>
+            <subsection name="Executing the Client">
+                <p>
+                    This is a combination of <a href="sample370.html">sample 370</a> and
+                    <a href="sample371.html">sample 371</a>. In this case the throttle policy is loaded
+                    from the 'throttle_policy.xml' file which is fetched from the registry. To verify
+                    the functionality, it requires running a load test. The all enabled request from
+                    the concurrency throttling will be controlled by the access rate base throttling
+                    according to the policy.
+                </p>
+                <p>
+                    Run the client as follows.
+                </p>
+                <div class="command">ant stockquote -Daddurl=http://localhost:8280/services/StockQuoteProxy</div>
+                <p>
+                    You will get same results as in <a href="sample371.html">sample 371</a>. If you
+                    run the load test, results will be different due to the effect of concurrency
+                    throttling.
+                </p>                
+            </subsection>
+        </section>
+        <p><a href="../samples.html">Back to Catalog</a></p>        
+    </body>
+</document>
\ No newline at end of file

Added: synapse/branches/2.1/src/site/xdoc/userguide/samples/sample380.xml
URL: http://svn.apache.org/viewvc/synapse/branches/2.1/src/site/xdoc/userguide/samples/sample380.xml?rev=1222320&view=auto
==============================================================================
--- synapse/branches/2.1/src/site/xdoc/userguide/samples/sample380.xml (added)
+++ synapse/branches/2.1/src/site/xdoc/userguide/samples/sample380.xml Thu Dec 22 16:16:02 2011
@@ -0,0 +1,204 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!--
+  ~  Licensed to the Apache Software Foundation (ASF) under one
+  ~  or more contributor license agreements.  See the NOTICE file
+  ~  distributed with this work for additional information
+  ~  regarding copyright ownership.  The ASF licenses this file
+  ~  to you under the Apache License, Version 2.0 (the
+  ~  "License"); you may not use this file except in compliance
+  ~  with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~  Unless required by applicable law or agreed to in writing,
+  ~  software distributed under the License is distributed on an
+  ~   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~  KIND, either express or implied.  See the License for the
+  ~  specific language governing permissions and limitations
+  ~  under the License.
+  -->
+
+<document>
+    <properties>
+        <title>Apache Synapse - Sample 380</title>
+    </properties>
+    <body>
+        <section name="Sample 380: Writing Custom Mediation Logic in Java">
+            <div class="xmlConf">&lt;definitions xmlns="http://ws.apache.org/ns/synapse"&gt;
+
+    &lt;sequence name="fault"&gt;
+        &lt;makefault&gt;
+            &lt;code xmlns:tns="http://www.w3.org/2003/05/soap-envelope" value="tns:Receiver"/&gt;
+            &lt;reason value="Mediation failed."/&gt;
+        &lt;/makefault&gt;
+        &lt;send/&gt;
+    &lt;/sequence&gt;
+
+    &lt;sequence name="main" onError="fault"&gt;
+        &lt;in&gt;
+            &lt;send&gt;
+                &lt;endpoint name="stockquote"&gt;
+                    &lt;address uri="http://localhost:9000/services/SimpleStockQuoteService"/&gt;
+                &lt;/endpoint&gt;
+            &lt;/send&gt;
+        &lt;/in&gt;
+        &lt;out&gt;
+            &lt;class name="samples.mediators.DiscountQuoteMediator"&gt;
+                &lt;property name="discountFactor" value="10"/&gt;
+                &lt;property name="bonusFor" value="5"/&gt;
+            &lt;/class&gt;
+            &lt;send/&gt;
+        &lt;/out&gt;
+    &lt;/sequence&gt;
+
+&lt;/definitions&gt;</div>
+            <subsection name="Objective">
+                <p>
+                    Demonstrate the use of class mediator to extend the mediation functionality of
+                    Synapse
+                </p>
+            </subsection>
+            <subsection name="Pre-requisites">
+                <p>
+                    <ul>
+                        <li>
+                            Deploy the SimpleStockQuoteService in the sample Axis2 server and start Axis2
+                        </li>
+                        <li>
+                            Start Synapse using the configuration numbered 380 (repository/conf/sample/synapse_sample_380.xml)
+                            <div class="command">
+                                Unix/Linux: sh synapse.sh -sample 380<br/>
+                                Windows: synapse.bat -sample 380
+                            </div>
+                        </li>
+                    </ul>
+                </p>
+            </subsection>
+            <subsection name="Executing the Client">
+                <p>
+                    In this configuration, Synapse hands over the request message to the specified
+                    endpoint, which sends it to the Axis2 server running on port 9000. But the response
+                    message is passed through the class mediator before sending it back to the client.
+                    Class mediator in turns hands over the message to the specified Java class for
+                    further processing. In that regard, the class mediator acts as a delegating
+                    mediator which delegates the message to a custom Java class for processing.
+                    Two parameters named 'discountFactor' and 'bonusFor' are passed to the mediator
+                    implementation class (i.e. samples.mediators.DiscountQuoteMediator) before each
+                    invocation. Source of the mediator implementation class is shown below. 
+                </p>
+                <div class="consoleOutput">package samples.mediators;
+
+import org.apache.synapse.MessageContext;
+import org.apache.synapse.Mediator;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.xml.namespace.QName;
+
+public class DiscountQuoteMediator implements Mediator {
+
+    private static final Log log = LogFactory.getLog(DiscountQuoteMediator.class);
+
+    private String discountFactor=&quot;10&quot;;
+
+    private String bonusFor=&quot;10&quot;;
+
+    private int bonusCount=0;
+
+    public DiscountQuoteMediator(){}
+
+    public boolean mediate(MessageContext mc) {
+
+        String price= mc.getEnvelope().getBody().getFirstElement().getFirstElement().
+                getFirstChildWithName(new QName(&quot;http://services.samples/xsd&quot;,&quot;last&quot;)).getText();
+
+        //converting String properties into integers
+        int discount=Integer.parseInt(discountFactor);
+        int bonusNo=Integer.parseInt(bonusFor);
+        double currentPrice=Double.parseDouble(price);
+
+        //discounting factor is deducted from current price form every response
+        Double lastPrice = new Double(currentPrice - currentPrice * discount / 100);
+
+        //Special discount of 5% offers for the first responses as set in the bonusFor property
+        if (bonusCount &lt;= bonusNo) {
+            lastPrice = new Double(lastPrice.doubleValue() - lastPrice.doubleValue() * 0.05);
+            bonusCount++;
+        }
+
+        String discountedPrice = lastPrice.toString();
+
+        mc.getEnvelope().getBody().getFirstElement().getFirstElement().getFirstChildWithName
+                (new QName(&quot;http://services.samples/xsd&quot;,&quot;last&quot;)).setText(discountedPrice);
+
+        System.out.println(&quot;Quote value discounted.&quot;);
+        System.out.println(&quot;Original price: &quot; + price);
+        System.out.println(&quot;Discounted price: &quot; + discountedPrice);
+
+        return true;
+    }
+
+    public String getType() {
+        return null;
+    }
+
+    public void setTraceState(int traceState) {
+        traceState = 0;
+    }
+
+    public int getTraceState() {
+        return 0;
+    }
+
+    public void setDiscountFactor(String discount) {
+        discountFactor=discount;
+    }
+
+    public String getDiscountFactor() {
+        return discountFactor;
+    }
+
+    public void setBonusFor(String bonus){
+        bonusFor=bonus;
+    }
+
+    public String getBonusFor(){
+        return bonusFor;
+    }
+}</div>
+                <p>
+                    All classes developed for the class mediator should implement the 'Mediator'
+                    interface, which contains the mediate(...) method. The mediate(...) method of the
+                    above class is invoked for each response message mediated through the main
+                    sequence, with the message context of the current message as the parameter. All
+                    details of the message including the SOAP headers, SOAP body and properties of
+                    the context hierarchy can be accessed from the message context. In this sample,
+                    the body of the message is retrieved and the discount percentage is subtracted
+                    from the quote price. If the quote request number is less than the number specified
+                    in the 'bonusFor' property in the configuration, a special discount is given.
+                </p>
+                <p>
+                    To test the custom code and the class mediator, invoke the test client as
+                    follows.
+                </p>
+                <div class="command">ant stockquote -Dsymbol=IBM -Dmode=quote -Daddurl=http://localhost:8280</div>
+                <p>
+                    You will see the below output in the client console with the discounted quote value.
+                </p>
+                <div class="consoleOutput">Standard :: Stock price = $95.26454380258552</div>
+                <p>
+                    If you check the Synapse console, you will notice the messages printed by the
+                    custom mediator during mediation.
+                </p>
+                <div class="consoleOutput">Quote value discounted.
+Original price: 162.30945327447262
+Discounted price: 138.77458254967408</div>
+            </subsection>
+        </section>
+        <p><a href="../samples.html">Back to Catalog</a></p>        
+    </body>
+</document>
\ No newline at end of file

Added: synapse/branches/2.1/src/site/xdoc/userguide/samples/sample381.xml
URL: http://svn.apache.org/viewvc/synapse/branches/2.1/src/site/xdoc/userguide/samples/sample381.xml?rev=1222320&view=auto
==============================================================================
--- synapse/branches/2.1/src/site/xdoc/userguide/samples/sample381.xml (added)
+++ synapse/branches/2.1/src/site/xdoc/userguide/samples/sample381.xml Thu Dec 22 16:16:02 2011
@@ -0,0 +1,134 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!--
+  ~  Licensed to the Apache Software Foundation (ASF) under one
+  ~  or more contributor license agreements.  See the NOTICE file
+  ~  distributed with this work for additional information
+  ~  regarding copyright ownership.  The ASF licenses this file
+  ~  to you under the Apache License, Version 2.0 (the
+  ~  "License"); you may not use this file except in compliance
+  ~  with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~  Unless required by applicable law or agreed to in writing,
+  ~  software distributed under the License is distributed on an
+  ~   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~  KIND, either express or implied.  See the License for the
+  ~  specific language governing permissions and limitations
+  ~  under the License.
+  -->
+
+<document>
+    <properties>
+        <title>Apache Synapse - Sample 381</title>
+    </properties>
+    <body>
+        <section name="Sample 381: Class Mediator for CBR of Binary Messages">
+            <div class="xmlConf">&lt;definitions xmlns="http://ws.apache.org/ns/synapse"&gt;
+
+    &lt;proxy name="JMSBinaryProxy" transports="jms"&gt;
+        &lt;target inSequence="BINARY_CBR_SEQ"/&gt;
+    &lt;/proxy&gt;
+
+    &lt;sequence name="BINARY_CBR_SEQ"&gt;
+        &lt;in&gt;
+            &lt;log level="full"/&gt;
+            &lt;property action="set" name="OUT_ONLY" value="true"/&gt;
+            &lt;class name="samples.mediators.BinaryExtractMediator"&gt;
+                &lt;property name="offset" value="11"/&gt;
+                &lt;property name="length" value="4"/&gt;
+                &lt;property name="variableName" value="symbol"/&gt;
+                &lt;property name="binaryEncoding" value="utf-8"/&gt;
+            &lt;/class&gt;
+            &lt;log level="custom"&gt;
+                &lt;property name="symbol" expression="get-property('symbol')"/&gt;
+            &lt;/log&gt;
+            &lt;switch source="get-property('symbol')"&gt;
+                &lt;case regex="GOOG"&gt;
+                    &lt;send&gt;
+                        &lt;endpoint&gt;
+                            &lt;address
+                                    uri="jms:/dynamicTopics/mdd.GOOG?transport.jms.ConnectionFactoryJNDIName=TopicConnectionFactory&amp;java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory&amp;java.naming.provider.url=tcp://localhost:61616&amp;transport.jms.DestinationType=topic"/&gt;
+                        &lt;/endpoint&gt;
+                    &lt;/send&gt;
+                &lt;/case&gt;
+                &lt;case regex="MSFT"&gt;
+                    &lt;send&gt;
+                        &lt;endpoint&gt;
+                            &lt;address
+                                    uri="jms:/dynamicTopics/mdd.MSFT?transport.jms.ConnectionFactoryJNDIName=TopicConnectionFactory&amp;java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory&amp;java.naming.provider.url=tcp://localhost:61616&amp;transport.jms.DestinationType=topic"/&gt;
+                        &lt;/endpoint&gt;
+                    &lt;/send&gt;
+                &lt;/case&gt;
+                &lt;default/&gt;
+            &lt;/switch&gt;
+        &lt;/in&gt;
+    &lt;/sequence&gt;
+
+&lt;/definitions&gt;</div>
+            <subsection name="Objective">
+                <p>
+                    Demonstrate an advanced content based routing (CBR) scenario using a custom mediator
+                </p>
+            </subsection>
+            <subsection name="Pre-requisites">
+                <p>
+                    <ul>                
+                        <li>
+                            Setup and start a JMS broker (Apache ActiveMQ can be used as the
+                            JMS broker for this scenario.Refer <a href="setup/jms.html#intro">JMS setup guide</a> for information on
+                            how to run ActiveMQ.)
+                        </li>
+                        <li>
+                            Enable the JMS transport receiver and sender of Synapse (Refer JMS setup
+                            guide for more details)
+                        </li>
+                        <li>
+                            Start Synapse using the configuration numbered 381 (repository/conf/sample/synapse_sample_381.xml)
+                            <div class="command">
+                                Unix/Linux: sh synapse.sh -sample 381<br/>
+                                Windows: synapse.bat -sample 381
+                            </div>
+                        </li>
+                    </ul>
+                </p>
+            </subsection>
+            <subsection name="Executing the Client">
+                <p>
+                    In this configuration, a proxy service has been defined to accept incoming JMS 
+                    messages. JMS messages contain binary payloads. User configures the offset, length,
+                    and binary encoding of the text literal that Synapse should use for CBR. Configuration
+                    simply routes the messages based on this text to different endpoints.
+                </p>
+                <p>
+                    A JMS producer and two instances of a consumer used to demonstrate the CBR functionality.
+                </p>
+                <p>
+                    Now run the first consumer using the following command.
+                </p>
+                <div class="command">ant mddconsumer -Djms_topic=mdd.MSFT</div>
+                <p>
+                    Now run the second consumer using the following command.
+                </p>
+                <div class="command">ant mddconsumer -Djms_topic=mdd.GOOG</div>
+                <p>
+                    Now run the market data producer to genenrate market data for symbol 'MSFT' using
+                    the following command.
+                </p>
+                <div class="command">ant mddproducer -Dsymbol=MSFT</div>
+                <p>
+                    Now run the market data producer to genenrate market data for symbol 'GOOG' using
+                    the following command.
+                </p>
+                <div class="command">ant mddproducer -Dsymbol=GOOG</div>
+                <p>
+                    You will see the below output in the client console(s) based on the symbol.
+                </p>
+                <div class="consoleOutput">mddconsumer:
+     [java]  Market data recived for symbol : topic://mdd.MSFT
+     [java]  Market data recived for symbol : topic://mdd.MSFT</div>
+            </subsection>
+        </section>
+        <p><a href="../samples.html">Back to Catalog</a></p>        
+    </body>
+</document>
\ No newline at end of file

Added: synapse/branches/2.1/src/site/xdoc/userguide/samples/sample390.xml
URL: http://svn.apache.org/viewvc/synapse/branches/2.1/src/site/xdoc/userguide/samples/sample390.xml?rev=1222320&view=auto
==============================================================================
--- synapse/branches/2.1/src/site/xdoc/userguide/samples/sample390.xml (added)
+++ synapse/branches/2.1/src/site/xdoc/userguide/samples/sample390.xml Thu Dec 22 16:16:02 2011
@@ -0,0 +1,114 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!--
+  ~  Licensed to the Apache Software Foundation (ASF) under one
+  ~  or more contributor license agreements.  See the NOTICE file
+  ~  distributed with this work for additional information
+  ~  regarding copyright ownership.  The ASF licenses this file
+  ~  to you under the Apache License, Version 2.0 (the
+  ~  "License"); you may not use this file except in compliance
+  ~  with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~  Unless required by applicable law or agreed to in writing,
+  ~  software distributed under the License is distributed on an
+  ~   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~  KIND, either express or implied.  See the License for the
+  ~  specific language governing permissions and limitations
+  ~  under the License.
+  -->
+
+<document>
+    <properties>
+        <title>Apache Synapse - Sample 390</title>
+    </properties>
+    <body>
+        <section name="Sample 390: Introduction to the XQuery Mediator">
+            <div class="xmlConf">&lt;definitions xmlns="http://ws.apache.org/ns/synapse"&gt;
+
+    &lt;!-- the SimpleURLRegistry allows access to a URL based registry (e.g. file:/// or http://) --&gt;
+    &lt;registry provider="org.apache.synapse.registry.url.SimpleURLRegistry"&gt;
+        &lt;!-- the root property of the simple URL registry helps resolve a resource URL as root + key --&gt;
+        &lt;parameter name="root"&gt;file:repository/conf/sample/resources/&lt;/parameter&gt;
+        &lt;!-- all resources loaded from the URL registry would be cached for this number of milli seconds --&gt;
+        &lt;parameter name="cachableDuration"&gt;15000&lt;/parameter&gt;
+    &lt;/registry&gt;
+
+    &lt;localEntry key="xquery-key-req"
+                src="file:repository/conf/sample/resources/xquery/xquery_req.xq"/&gt;
+
+    &lt;proxy name="StockQuoteProxy"&gt;
+        &lt;target&gt;
+            &lt;inSequence&gt;
+                &lt;property name="body" expression="$body/child::*[position()=1]"/&gt;
+                &lt;xquery key="xquery-key-req"&gt;
+                    &lt;variable name="payload" type="ELEMENT"/&gt;
+                &lt;/xquery&gt;
+                &lt;send&gt;
+                    &lt;endpoint&gt;
+                        &lt;address uri="http://localhost:9000/services/SimpleStockQuoteService"/&gt;
+                    &lt;/endpoint&gt;
+                &lt;/send&gt;
+            &lt;/inSequence&gt;
+            &lt;outSequence&gt;
+                &lt;out&gt;
+                    &lt;xquery key="xquery/xquery_res.xq"&gt;
+                        &lt;variable name="payload" type="ELEMENT"/&gt;
+                        &lt;variable xmlns:m0="http://services.samples"
+                                  xmlns:ax21="http://services.samples/xsd" name="code" type="STRING"
+                                  expression="self::node()//m0:return/ax21:symbol/child::text()"/&gt;
+                        &lt;variable xmlns:m0="http://services.samples"
+                                  xmlns:ax21="http://services.samples/xsd" name="price"
+                                  type="DOUBLE"
+                                  expression="self::node()//m0:return/ax21:last/child::text()"/&gt;
+                    &lt;/xquery&gt;
+                    &lt;send/&gt;
+                &lt;/out&gt;
+            &lt;/outSequence&gt;
+        &lt;/target&gt;
+        &lt;publishWSDL uri="file:repository/conf/sample/resources/proxy/sample_proxy_1.wsdl"/&gt;
+    &lt;/proxy&gt;
+
+&lt;/definitions&gt;</div>
+            <subsection name="Objective">
+                <p>
+                    Demonstrate how to use the XQuery mediator for message content transformations
+                </p>
+            </subsection>
+            <subsection name="Pre-requisites">
+                <p>
+                    <ul>
+                        <li>
+                            Deploy the SimpleStockQuoteService in the sample Axis2 server and start Axis2
+                        </li>
+                        <li>
+                            Start Synapse using the configuration numbered 390 (repository/conf/sample/synapse_sample_390.xml)
+                            <div class="command">
+                                Unix/Linux: sh synapse.sh -sample 390<br/>
+                                Windows: synapse.bat -sample 390
+                            </div>
+                        </li>
+                    </ul>
+                </p>
+            </subsection>
+            <subsection name="Executing the Client">
+                <p>
+                    This example uses the XQuery mediator to perform transformations. This sample
+                    behaves the same as <a href="sample8.html">sample 8</a> and the only difference
+                    is that this sample uses XQuery instead of XSLT for transformation.
+                </p>
+                <p>
+                    Send a custom quote request to Synapse as follows.
+                </p>
+                <div class="command">ant stockquote -Daddurl=http://localhost:8280/services/StockQuoteProxy -Dmode=customquote</div>
+                <p>
+                    Request is transformed into a standard stock quote request by the XPery mediator.
+                    The XQuery definition is loaded through a local entry. The response from Axis2
+                    is transformed back to a custom quote response. In this case the XQuery definition
+                    is loaded from the registry.
+                </p>
+            </subsection>
+        </section>
+        <p><a href="../samples.html">Back to Catalog</a></p>        
+    </body>
+</document>
\ No newline at end of file

Added: synapse/branches/2.1/src/site/xdoc/userguide/samples/sample391.xml
URL: http://svn.apache.org/viewvc/synapse/branches/2.1/src/site/xdoc/userguide/samples/sample391.xml?rev=1222320&view=auto
==============================================================================
--- synapse/branches/2.1/src/site/xdoc/userguide/samples/sample391.xml (added)
+++ synapse/branches/2.1/src/site/xdoc/userguide/samples/sample391.xml Thu Dec 22 16:16:02 2011
@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!--
+  ~  Licensed to the Apache Software Foundation (ASF) under one
+  ~  or more contributor license agreements.  See the NOTICE file
+  ~  distributed with this work for additional information
+  ~  regarding copyright ownership.  The ASF licenses this file
+  ~  to you under the Apache License, Version 2.0 (the
+  ~  "License"); you may not use this file except in compliance
+  ~  with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~  Unless required by applicable law or agreed to in writing,
+  ~  software distributed under the License is distributed on an
+  ~   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~  KIND, either express or implied.  See the License for the
+  ~  specific language governing permissions and limitations
+  ~  under the License.
+  -->
+
+<document>
+    <properties>
+        <title>Apache Synapse - Sample 391</title>
+    </properties>
+    <body>
+        <section name="Sample 391: Using External XML Documents in the XQuery Mediator">
+            <div class="xmlConf">&lt;definitions xmlns="http://ws.apache.org/ns/synapse"&gt;
+
+    &lt;!-- the SimpleURLRegistry allows access to a URL based registry (e.g. file:/// or http://) --&gt;
+    &lt;registry provider="org.apache.synapse.registry.url.SimpleURLRegistry"&gt;
+        &lt;!-- the root property of the simple URL registry helps resolve a resource URL as root + key --&gt;
+        &lt;parameter name="root"&gt;file:repository/conf/sample/resources/&lt;/parameter&gt;
+        &lt;!-- all resources loaded from the URL registry would be cached for this number of milli seconds --&gt;
+        &lt;parameter name="cachableDuration"&gt;15000&lt;/parameter&gt;
+    &lt;/registry&gt;
+
+    &lt;proxy name="StockQuoteProxy"&gt;
+        &lt;target&gt;
+            &lt;inSequence&gt;
+                &lt;send&gt;
+                    &lt;endpoint&gt;
+                        &lt;address uri="http://localhost:9000/services/SimpleStockQuoteService"/&gt;
+                    &lt;/endpoint&gt;
+                &lt;/send&gt;
+            &lt;/inSequence&gt;
+            &lt;outSequence&gt;
+                &lt;out&gt;
+                    &lt;xquery key="xquery/xquery_commisson.xq"&gt;
+                        &lt;variable name="payload" type="ELEMENT"/&gt;
+                        &lt;variable name="commission" type="ELEMENT" key="misc/commission.xml"/&gt;
+                    &lt;/xquery&gt;
+                    &lt;send/&gt;
+                &lt;/out&gt;
+            &lt;/outSequence&gt;
+        &lt;/target&gt;
+        &lt;publishWSDL uri="file:repository/conf/sample/resources/proxy/sample_proxy_1.wsdl"/&gt;
+    &lt;/proxy&gt;
+
+&lt;/definitions&gt;</div>
+            <subsection name="Objective">
+                <p>
+                    Demonstrate how to import external XML documents into the XQuery engine using
+                    the XQuery mediator
+                </p>
+            </subsection>
+            <subsection name="Pre-requisites">
+                <p>
+                    <ul>
+                        <li>
+                            Deploy the SimpleStockQuoteService in the sample Axis2 server and start Axis2
+                        </li>
+                        <li>
+                            Start Synapse using the configuration numbered 391 (repository/conf/sample/synapse_sample_391.xml)
+                            <div class="command">
+                                Unix/Linux: sh synapse.sh -sample 391<br/>
+                                Windows: synapse.bat -sample 391
+                            </div>
+                        </li>
+                    </ul>
+                </p>
+            </subsection>
+            <subsection name="Executing the Client">
+                <p>
+                    In this sample, data from commission.xml file is used inside XQuery. The stock
+                    quote price from the response and commission from the commission.xml document
+                    will be added and given as a new price value.
+                </p>
+                <p>
+                    Try out this sample by invoking the proxy service as follows.
+                </p>
+                <div class="command">ant stockquote -Daddurl=http://localhost:8280/services/StockQuoteProxy</div>
+            </subsection>
+        </section>
+        <p><a href="../samples.html">Back to Catalog</a></p>        
+    </body>
+</document>
\ No newline at end of file

Added: synapse/branches/2.1/src/site/xdoc/userguide/samples/sample4.xml
URL: http://svn.apache.org/viewvc/synapse/branches/2.1/src/site/xdoc/userguide/samples/sample4.xml?rev=1222320&view=auto
==============================================================================
--- synapse/branches/2.1/src/site/xdoc/userguide/samples/sample4.xml (added)
+++ synapse/branches/2.1/src/site/xdoc/userguide/samples/sample4.xml Thu Dec 22 16:16:02 2011
@@ -0,0 +1,156 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!--
+  ~  Licensed to the Apache Software Foundation (ASF) under one
+  ~  or more contributor license agreements.  See the NOTICE file
+  ~  distributed with this work for additional information
+  ~  regarding copyright ownership.  The ASF licenses this file
+  ~  to you under the Apache License, Version 2.0 (the
+  ~  "License"); you may not use this file except in compliance
+  ~  with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~  Unless required by applicable law or agreed to in writing,
+  ~  software distributed under the License is distributed on an
+  ~   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~  KIND, either express or implied.  See the License for the
+  ~  specific language governing permissions and limitations
+  ~  under the License.
+  -->
+
+<document>
+    <properties>
+        <title>Apache Synapse - Sample 4</title>
+    </properties>
+    <body>
+        <section name="Sample 4: Introduction to Error Handling">
+            <div class="xmlConf">&lt;definitions xmlns="http://ws.apache.org/ns/synapse"&gt;
+
+    &lt;!-- the default fault handling sequence used by Synapse - named 'fault' --&gt;
+    &lt;sequence name="fault"&gt;
+        &lt;log level="custom"&gt;
+            &lt;property name="text" value="An unexpected error occured"/&gt;
+            &lt;property name="message" expression="get-property('ERROR_MESSAGE')"/&gt;
+        &lt;/log&gt;
+        &lt;drop/&gt;
+    &lt;/sequence&gt;
+
+    &lt;sequence name="sunErrorHandler"&gt;
+        &lt;log level="custom"&gt;
+            &lt;property name="text" value="An unexpected error occured for stock SUN"/&gt;
+            &lt;property name="message" expression="get-property('ERROR_MESSAGE')"/&gt;
+            &lt;!--&lt;property name="detail" expression="get-property('ERROR_DETAIL')"/&gt;--&gt;
+        &lt;/log&gt;
+        &lt;drop/&gt;
+    &lt;/sequence&gt;
+
+    &lt;sequence name="main"&gt;
+        &lt;in&gt;
+            &lt;switch xmlns:m0="http://services.samples" source="//m0:getQuote/m0:request/m0:symbol"&gt;
+                &lt;case regex="IBM"&gt;
+                    &lt;send&gt;
+                        &lt;endpoint&gt;
+                            &lt;address uri="http://localhost:9000/services/SimpleStockQuoteService"/&gt;
+                        &lt;/endpoint&gt;
+                    &lt;/send&gt;
+                &lt;/case&gt;
+                &lt;case regex="MSFT"&gt;
+                    &lt;send&gt;
+                        &lt;endpoint key="bogus"/&gt;
+                    &lt;/send&gt;
+                &lt;/case&gt;
+                &lt;case regex="SUN"&gt;
+                    &lt;sequence key="sunSequence"/&gt;
+                &lt;/case&gt;
+            &lt;/switch&gt;
+            &lt;drop/&gt;
+        &lt;/in&gt;
+
+        &lt;out&gt;
+            &lt;send/&gt;
+        &lt;/out&gt;
+    &lt;/sequence&gt;
+
+    &lt;sequence name="sunSequence" onError="sunErrorHandler"&gt;
+        &lt;send&gt;
+            &lt;endpoint key="sunPort"/&gt;
+        &lt;/send&gt;
+    &lt;/sequence&gt;
+
+&lt;/definitions&gt;</div>
+            <subsection name="Objective">
+                <p>
+                    Introduction to error handling with the 'fault' sequence
+                </p>
+            </subsection>
+            <subsection name="Pre-requisites">
+                <p>
+                    <ul>
+                        <li>
+                            Deploy the SimpleStockQuoteService in the sample Axis2 server and start Axis2
+                        </li>
+                        <li>
+                            Start Synapse using the configuration numbered 4 (repository/conf/sample/synapse_sample_4.xml)
+                            <div class="command">
+                                Unix/Linux: sh synapse.sh -sample 4<br/>
+                                Windows: synapse.bat -sample 4
+                            </div>
+                        </li>
+                    </ul>
+                </p>
+            </subsection>
+            <subsection name="Executing the Client">
+                <p>
+                    First send a stock quote request from the sample client 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>
+                    The request will be routed to the Axis2 server and client will receive a response
+                    as expected.
+                </p>
+                <div class="consoleOutput">Standard :: Stock price = $95.26454380258552</div>
+                <p>
+                    Now send another stock quote request for the symbol 'MSFT' as follows.
+                </p>
+                <div class="command">ant stockquote -Daddurl=http://localhost:9000/services/SimpleStockQuoteService -Dtrpurl=http://localhost:8280/ -Dsymbol=MSFT</div>
+                <p>
+                    For MSFT requests Synapse is instructed to route the messages to an endpoint named
+                    'bogus', which does not exist. Synapse executes the specified error handler
+                    sequence closest to the point where the error was encountered. In this case, the
+                    currently executing sequence is 'main' and it does not specify an 'onError'
+                    attribute. Whenever Synapse cannot find an error handler, it looks for a sequence
+                    named 'fault'. Thus the 'fault' sequence can be seen executing, and writing the
+                    generic error message to the logs.
+                </p>
+                <div class="consoleOutput">[HttpServerWorker-1] DEBUG SendMediator - Send mediator :: mediate()
+[HttpServerWorker-1] ERROR IndirectEndpoint - Reference to non-existent endpoint for key : bogus
+[HttpServerWorker-1] DEBUG MediatorFaultHandler - MediatorFaultHandler :: handleFault
+[HttpServerWorker-1] DEBUG SequenceMediator - Sequence mediator &lt;fault&gt; :: mediate()
+[HttpServerWorker-1] DEBUG LogMediator - Log mediator :: mediate()
+[HttpServerWorker-1] INFO LogMediator text = An unexpected error occured, message = Couldn't find the endpoint with the key : bogus</div>
+                <p>
+                    Now send another stock quote request for the symbol 'SUN'.
+                </p>
+                <div class="command">ant stockquote -Daddurl=http://localhost:9000/services/SimpleStockQuoteService -Dtrpurl=http://localhost:8280/ -Dsymbol=SUN</div>
+                <p>
+                    When the 'SUN' quote is requested, a custom sequence 'sunSequence' is invoked,
+                    and it specifies 'sunErrorHandler' as its error handler. Hence when the send
+                    fails, you could see the proper error handler invocation and the custom error
+                    message printed as follows.
+                </p>
+                <div class="consoleOutput">[HttpServerWorker-1] DEBUG SequenceMediator - Sequence mediator &lt;sunSequence&gt; :: mediate()
+[HttpServerWorker-1] DEBUG SequenceMediator - Setting the onError handler for the sequence
+[HttpServerWorker-1] DEBUG AbstractListMediator - Implicit Sequence &lt;SequenceMediator&gt; :: mediate()
+[HttpServerWorker-1] DEBUG SendMediator - Send mediator :: mediate()
+[HttpServerWorker-1] ERROR IndirectEndpoint - Reference to non-existent endpoint for key : sunPort
+[HttpServerWorker-1] DEBUG MediatorFaultHandler - MediatorFaultHandler :: handleFault
+[HttpServerWorker-1] DEBUG SequenceMediator - Sequence mediator &lt;sunErrorHandler&gt; :: mediate()
+[HttpServerWorker-1] DEBUG AbstractListMediator - Implicit Sequence &lt;SequenceMediator&gt; :: mediate()
+[HttpServerWorker-1] DEBUG LogMediator - Log mediator :: mediate()
+[HttpServerWorker-1] INFO LogMediator text = An unexpected error occured for stock SUN, message = Couldn't find the endpoint with the key : sunPort</div>
+            </subsection>
+        </section>
+        <p><a href="../samples.html">Back to Catalog</a></p>        
+    </body>
+</document>
\ No newline at end of file