Added: synapse/site/3_0_2/userguide/samples/sample363.html URL: http://svn.apache.org/viewvc/synapse/site/3_0_2/userguide/samples/sample363.html?rev=1909775&view=auto ============================================================================== --- synapse/site/3_0_2/userguide/samples/sample363.html (added) +++ synapse/site/3_0_2/userguide/samples/sample363.html Fri May 12 16:09:34 2023 @@ -0,0 +1,300 @@ +<!DOCTYPE html> +<!-- + | Generated by Apache Maven Doxia Site Renderer 1.7.4 at 2023-05-04 + | Rendered using Apache Maven Fluido Skin 1.6 +--> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> + <head> + <meta charset="UTF-8" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + <meta name="Date-Revision-yyyymmdd" content="20230504" /> + <meta http-equiv="Content-Language" content="en" /> + <title>Apache Synapse – Apache Synapse - Sample 363</title> + <link rel="stylesheet" href="../../css/apache-maven-fluido-1.6.min.css" /> + <link rel="stylesheet" href="../../css/site.css" /> + <link rel="stylesheet" href="../../css/print.css" media="print" /> + <script type="text/javascript" src="../../js/apache-maven-fluido-1.6.min.js"></script> + </head> + <body class="topBarDisabled"> + <div class="container-fluid"> + <div id="banner"> + <div class="pull-left"><div id="bannerLeft"><h2>Apache Synapse</h2> +</div> +</div> + <div class="pull-right"></div> + <div class="clear"><hr/></div> + </div> + + <div id="breadcrumbs"> + <ul class="breadcrumb"> + <li id="publishDate">Last Published: 2023-05-04<span class="divider">|</span> +</li> + <li id="projectVersion">Version: 3.0.2</li> + </ul> + </div> + <div class="row-fluid"> + <div id="leftColumn" class="span2"> + <div class="well sidebar-nav"> +<ul class="nav nav-list"> + <li class="nav-header">Main Menu</li> + <li><a href="../../index.html" title="Home"><span class="none"></span>Home</a> </li> + <li><a href="../../download.html" title="Download"><span class="none"></span>Download</a> </li> + <li><a href="../../history.html" title="History"><span class="none"></span>History</a> </li> + <li><a href="http://www.apache.org/licenses/LICENSE-2.0" class="externalLink" title="License"><span class="none"></span>License</a> </li> + <li><a href="http://www.apache.org/foundation/thanks.html" class="externalLink" title="Thanks"><span class="none"></span>Thanks</a> </li> + <li><a href="http://www.apache.org/foundation/sponsorship.html" class="externalLink" title="Sponsorship"><span class="none"></span>Sponsorship</a> </li> + <li><a href="http://www.apache.org/security/" class="externalLink" title="Security"><span class="none"></span>Security</a> </li> + <li class="nav-header">Documentation</li> + <li><a href="../../userguide/installation.html" title="Installation Guide"><span class="none"></span>Installation Guide</a> </li> + <li><a href="../../userguide/quick_start.html" title="Quick Start Guide"><span class="none"></span>Quick Start Guide</a> </li> + <li><a href="../../userguide/samples/setup/index.html" title="Samples Setup Guide"><span class="none"></span>Samples Setup Guide</a> </li> + <li><a href="../../userguide/samples.html" title="Samples Catalog"><span class="none"></span>Samples Catalog</a> </li> + <li><a href="../../userguide/config.html" title="Configuration Language"><span class="none"></span>Configuration Language</a> </li> + <li><a href="../../userguide/mediators.html" title="Mediators Catalog"><span class="none"></span>Mediators Catalog</a> </li> + <li><a href="../../userguide/transports.html" title="Transports Catalog"><span class="none"></span>Transports Catalog</a> </li> + <li><a href="../../userguide/properties.html" title="Properties Catalog"><span class="none"></span>Properties Catalog</a> </li> + <li><a href="../../userguide/xpath.html" title="XPath functions and Variables"><span class="none"></span>XPath functions and Variables</a> </li> + <li><a href="../../userguide/extending.html" title="Extending Synapse"><span class="none"></span>Extending Synapse</a> </li> + <li><a href="../../userguide/template_library.html" title="Synapse Template Libraries"><span class="none"></span>Synapse Template Libraries</a> </li> + <li><a href="../../userguide/upgrading.html" title="Upgrading"><span class="none"></span>Upgrading</a> </li> + <li><a href="../../userguide/deployment.html" title="Deployment"><span class="none"></span>Deployment</a> </li> + <li><a href="../../apidocs/" title="Javadocs"><span class="none"></span>Javadocs</a> </li> + <li><a href="../../userguide/faq.html" title="FAQ"><span class="none"></span>FAQ</a> </li> + <li class="nav-header">Developer Resources</li> + <li><a href="../../dev/developer-guide.html" title="Developer Guide"><span class="none"></span>Developer Guide</a> </li> + <li><a href="../../dev/best-practices.html" title="Development Best Practices"><span class="none"></span>Development Best Practices</a> </li> + <li><a href="../../dev/release-process.html" title="Release Process"><span class="none"></span>Release Process</a> </li> + <li class="nav-header">Project Details</li> + <li><a href="../../project-info.html" title="Overview"><span class="none"></span>Overview</a> </li> + <li><a href="../../mail-lists.html" title="Mailing Lists"><span class="none"></span>Mailing Lists</a> </li> + <li><a href="../../source-repository.html" title="Source Repository"><span class="none"></span>Source Repository</a> </li> + <li><a href="../../issue-tracking.html" title="Issue Tracking"><span class="none"></span>Issue Tracking</a> </li> + <li><a href="../../dependency-management.html" title="Dependencies"><span class="none"></span>Dependencies</a> </li> + <li><a href="../../team-list.html" title="Project Team"><span class="none"></span>Project Team</a> </li> + </ul> + <hr /> + <div id="poweredBy"> + <div class="clear"></div> + <div class="clear"></div> + <div class="clear"></div> + <div class="clear"></div> + <a href="http://maven.apache.org/" title="Built by Maven" class="poweredBy"><img class="builtBy" alt="Built by Maven" src="../../images/logos/maven-feather.png" /></a> + </div> + </div> + </div> + <div id="bodyColumn" class="span10" > + + + <div class="section"> +<h2><a name="Sample_363:_Reusable_Database_Connection_Pools"></a>Sample 363: Reusable Database Connection Pools</h2> + +<div class="xmlConf"><definitions xmlns="http://ws.apache.org/ns/synapse"> + + <sequence name="myFaultHandler"> + <makefault response="true"> + <code xmlns:tns="http://www.w3.org/2003/05/soap-envelope" value="tns:Receiver"/> + <reason expression="get-property('ERROR_MESSAGE')"/> + </makefault> + <send/> + <drop/> + </sequence> + + <sequence name="main" onError="myFaultHandler"> + <in> + <log level="custom"> + <property name="text" value="** Looking up from the Database **"/> + </log> + <dblookup> + <connection> + <pool> + <dsName>lookupdb</dsName> + </pool> + </connection> + <statement> + <sql>select * from company where name =?</sql> + <parameter xmlns:m0="http://services.samples" + expression="//m0:getQuote/m0:request/m0:symbol" type="VARCHAR"/> + <result name="company_id" column="id"/> + </statement> + </dblookup> + + <switch source="get-property('company_id')"> + <case regex="c1"> + <log level="custom"> + <property name="text" + expression="fn:concat('Company ID - ',get-property('company_id'))"/> + </log> + <send> + <endpoint> + <address uri="http://localhost:9000/services/SimpleStockQuoteService"/> + </endpoint> + </send> + </case> + <case regex="c2"> + <log level="custom"> + <property name="text" + expression="fn:concat('Company ID - ',get-property('company_id'))"/> + </log> + <send> + <endpoint> + <address uri="http://localhost:9000/services/SimpleStockQuoteService"/> + </endpoint> + </send> + </case> + <case regex="c3"> + <log level="custom"> + <property name="text" + expression="fn:concat('Company ID - ',get-property('company_id'))"/> + </log> + <send> + <endpoint> + <address uri="http://localhost:9000/services/SimpleStockQuoteService"/> + </endpoint> + </send> + </case> + <default> + <log level="custom"> + <property name="text" value="** Unrecognized Company ID **"/> + </log> + <makefault response="true"> + <code xmlns:tns="http://www.w3.org/2003/05/soap-envelope" + value="tns:Receiver"/> + <reason value="** Unrecognized Company ID **"/> + </makefault> + <send/> + <drop/> + </default> + </switch> + <drop/> + </in> + + <out> + <log level="custom"> + <property name="text" value="** Reporting to the Database **"/> + </log> + <dbreport> + <connection> + <pool> + <dsName>reportdb</dsName> + </pool> + </connection> + <statement> + <sql>update company set price=? where name =?</sql> + <parameter xmlns:m0="http://services.samples" + expression="//m0:return/m0:last/child::text()" type="DOUBLE"/> + <parameter xmlns:m0="http://services.samples" + expression="//m0:return/m0:symbol/child::text()" type="VARCHAR"/> + </statement> + </dbreport> + <log level="custom"> + <property name="text" value="** Looking up from the Database **"/> + </log> + <dblookup> + <connection> + <pool> + <dsName>reportdb</dsName> + </pool> + </connection> + <statement> + <sql>select * from company where name =?</sql> + <parameter xmlns:m0="http://services.samples" + expression="//m0:return/m0:symbol/child::text()" type="VARCHAR"/> + <result name="stock_price" column="price"/> + </statement> + </dblookup> + <log level="custom"> + <property name="text" + expression="fn:concat('Stock price - ',get-property('stock_price'))"/> + </log> + <send/> + + </out> + + </sequence> + +</definitions></div> + +<div class="section"> +<h3><a name="Objective"></a>Objective</h3> + +<p> + Demonstrate how to setup reusable connection pools for the dblookup and dbreport + mediators + </p> + </div> + +<div class="section"> +<h3><a name="Pre-requisites"></a>Pre-requisites</h3> + +<p> + </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> + + </div> + +<div class="section"> +<h3><a name="Executing_the_Client"></a>Executing the Client</h3> + +<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> + </div> + </div> + +<p><a href="../samples.html">Back to Catalog</a></p> + + + </div> + </div> + </div> + <hr/> + <footer> + <div class="container-fluid"> + <div class="row-fluid"> + <p>Copyright ©2005–2023 +<a href="http://www.apache.org/">Apache Software Foundation</a>. +All rights reserved.</p> + </div> + </div> + </footer> + </body> +</html>
Added: synapse/site/3_0_2/userguide/samples/sample364.html URL: http://svn.apache.org/viewvc/synapse/site/3_0_2/userguide/samples/sample364.html?rev=1909775&view=auto ============================================================================== --- synapse/site/3_0_2/userguide/samples/sample364.html (added) +++ synapse/site/3_0_2/userguide/samples/sample364.html Fri May 12 16:09:34 2023 @@ -0,0 +1,238 @@ +<!DOCTYPE html> +<!-- + | Generated by Apache Maven Doxia Site Renderer 1.7.4 at 2023-05-04 + | Rendered using Apache Maven Fluido Skin 1.6 +--> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> + <head> + <meta charset="UTF-8" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + <meta name="Date-Revision-yyyymmdd" content="20230504" /> + <meta http-equiv="Content-Language" content="en" /> + <title>Apache Synapse – Apache Synapse - Sample 364</title> + <link rel="stylesheet" href="../../css/apache-maven-fluido-1.6.min.css" /> + <link rel="stylesheet" href="../../css/site.css" /> + <link rel="stylesheet" href="../../css/print.css" media="print" /> + <script type="text/javascript" src="../../js/apache-maven-fluido-1.6.min.js"></script> + </head> + <body class="topBarDisabled"> + <div class="container-fluid"> + <div id="banner"> + <div class="pull-left"><div id="bannerLeft"><h2>Apache Synapse</h2> +</div> +</div> + <div class="pull-right"></div> + <div class="clear"><hr/></div> + </div> + + <div id="breadcrumbs"> + <ul class="breadcrumb"> + <li id="publishDate">Last Published: 2023-05-04<span class="divider">|</span> +</li> + <li id="projectVersion">Version: 3.0.2</li> + </ul> + </div> + <div class="row-fluid"> + <div id="leftColumn" class="span2"> + <div class="well sidebar-nav"> +<ul class="nav nav-list"> + <li class="nav-header">Main Menu</li> + <li><a href="../../index.html" title="Home"><span class="none"></span>Home</a> </li> + <li><a href="../../download.html" title="Download"><span class="none"></span>Download</a> </li> + <li><a href="../../history.html" title="History"><span class="none"></span>History</a> </li> + <li><a href="http://www.apache.org/licenses/LICENSE-2.0" class="externalLink" title="License"><span class="none"></span>License</a> </li> + <li><a href="http://www.apache.org/foundation/thanks.html" class="externalLink" title="Thanks"><span class="none"></span>Thanks</a> </li> + <li><a href="http://www.apache.org/foundation/sponsorship.html" class="externalLink" title="Sponsorship"><span class="none"></span>Sponsorship</a> </li> + <li><a href="http://www.apache.org/security/" class="externalLink" title="Security"><span class="none"></span>Security</a> </li> + <li class="nav-header">Documentation</li> + <li><a href="../../userguide/installation.html" title="Installation Guide"><span class="none"></span>Installation Guide</a> </li> + <li><a href="../../userguide/quick_start.html" title="Quick Start Guide"><span class="none"></span>Quick Start Guide</a> </li> + <li><a href="../../userguide/samples/setup/index.html" title="Samples Setup Guide"><span class="none"></span>Samples Setup Guide</a> </li> + <li><a href="../../userguide/samples.html" title="Samples Catalog"><span class="none"></span>Samples Catalog</a> </li> + <li><a href="../../userguide/config.html" title="Configuration Language"><span class="none"></span>Configuration Language</a> </li> + <li><a href="../../userguide/mediators.html" title="Mediators Catalog"><span class="none"></span>Mediators Catalog</a> </li> + <li><a href="../../userguide/transports.html" title="Transports Catalog"><span class="none"></span>Transports Catalog</a> </li> + <li><a href="../../userguide/properties.html" title="Properties Catalog"><span class="none"></span>Properties Catalog</a> </li> + <li><a href="../../userguide/xpath.html" title="XPath functions and Variables"><span class="none"></span>XPath functions and Variables</a> </li> + <li><a href="../../userguide/extending.html" title="Extending Synapse"><span class="none"></span>Extending Synapse</a> </li> + <li><a href="../../userguide/template_library.html" title="Synapse Template Libraries"><span class="none"></span>Synapse Template Libraries</a> </li> + <li><a href="../../userguide/upgrading.html" title="Upgrading"><span class="none"></span>Upgrading</a> </li> + <li><a href="../../userguide/deployment.html" title="Deployment"><span class="none"></span>Deployment</a> </li> + <li><a href="../../apidocs/" title="Javadocs"><span class="none"></span>Javadocs</a> </li> + <li><a href="../../userguide/faq.html" title="FAQ"><span class="none"></span>FAQ</a> </li> + <li class="nav-header">Developer Resources</li> + <li><a href="../../dev/developer-guide.html" title="Developer Guide"><span class="none"></span>Developer Guide</a> </li> + <li><a href="../../dev/best-practices.html" title="Development Best Practices"><span class="none"></span>Development Best Practices</a> </li> + <li><a href="../../dev/release-process.html" title="Release Process"><span class="none"></span>Release Process</a> </li> + <li class="nav-header">Project Details</li> + <li><a href="../../project-info.html" title="Overview"><span class="none"></span>Overview</a> </li> + <li><a href="../../mail-lists.html" title="Mailing Lists"><span class="none"></span>Mailing Lists</a> </li> + <li><a href="../../source-repository.html" title="Source Repository"><span class="none"></span>Source Repository</a> </li> + <li><a href="../../issue-tracking.html" title="Issue Tracking"><span class="none"></span>Issue Tracking</a> </li> + <li><a href="../../dependency-management.html" title="Dependencies"><span class="none"></span>Dependencies</a> </li> + <li><a href="../../team-list.html" title="Project Team"><span class="none"></span>Project Team</a> </li> + </ul> + <hr /> + <div id="poweredBy"> + <div class="clear"></div> + <div class="clear"></div> + <div class="clear"></div> + <div class="clear"></div> + <a href="http://maven.apache.org/" title="Built by Maven" class="poweredBy"><img class="builtBy" alt="Built by Maven" src="../../images/logos/maven-feather.png" /></a> + </div> + </div> + </div> + <div id="bodyColumn" class="span10" > + + + <div class="section"> +<h2><a name="Sample_364:_Executing_Database_Stored_Procedures"></a>Sample 364: Executing Database Stored Procedures</h2> + +<div class="xmlConf"><definitions xmlns="http://ws.apache.org/ns/synapse"> + + <sequence name="main"> + <in> + <send> + <endpoint> + <address uri="http://localhost:9000/services/SimpleStockQuoteService"/> + </endpoint> + </send> + </in> + + <out> + <log level="custom"> + <property name="text" value="** Reporting to the Database **"/> + </log> + + <dbreport> + <connection> + <pool> + <driver>com.mysql.jdbc.Driver</driver> + <url>jdbc:mysql://localhost:3306/synapsedb</url> + <user>user</user> + <password>password</password> + </pool> + </connection> + <statement> + <sql>call updateCompany(?,?)</sql> + <parameter xmlns:m0="http://services.samples" + expression="//m0:return/m0:last/child::text()" type="DOUBLE"/> + <parameter xmlns:m0="http://services.samples" + expression="//m0:return/m0:symbol/child::text()" type="VARCHAR"/> + </statement> + </dbreport> + <log level="custom"> + <property name="text" value="** Looking up from the Database **"/> + </log> + <dblookup> + <connection> + <pool> + <driver>com.mysql.jdbc.Driver</driver> + <url>jdbc:mysql://localhost:3306/synapsedb</url> + <user>user</user> + <password>password</password> + </pool> + </connection> + <statement> + <sql>call getCompany(?)</sql> + <parameter xmlns:m0="http://services.samples" + expression="//m0:return/m0:symbol/child::text()" type="VARCHAR"/> + <result name="stock_prize" column="price"/> + </statement> + </dblookup> + <log level="custom"> + <property name="text" + expression="fn:concat('Stock Prize - ',get-property('stock_prize'))"/> + </log> + <send/> + </out> + </sequence> + +</definitions></div> + +<div class="section"> +<h3><a name="Objective"></a>Objective</h3> + +<p> + Demonstrate how to invoke a database stored procedure from Synapse + </p> + </div> + +<div class="section"> +<h3><a name="Pre-requisites"></a>Pre-requisites</h3> + +<p> + </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> + + </div> + +<div class="section"> +<h3><a name="Executing_the_Client"></a>Executing the Client</h3> + +<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> + </div> + </div> + +<p><a href="../samples.html">Back to Catalog</a></p> + + + </div> + </div> + </div> + <hr/> + <footer> + <div class="container-fluid"> + <div class="row-fluid"> + <p>Copyright ©2005–2023 +<a href="http://www.apache.org/">Apache Software Foundation</a>. +All rights reserved.</p> + </div> + </div> + </footer> + </body> +</html> Added: synapse/site/3_0_2/userguide/samples/sample370.html URL: http://svn.apache.org/viewvc/synapse/site/3_0_2/userguide/samples/sample370.html?rev=1909775&view=auto ============================================================================== --- synapse/site/3_0_2/userguide/samples/sample370.html (added) +++ synapse/site/3_0_2/userguide/samples/sample370.html Fri May 12 16:09:34 2023 @@ -0,0 +1,211 @@ +<!DOCTYPE html> +<!-- + | Generated by Apache Maven Doxia Site Renderer 1.7.4 at 2023-05-04 + | Rendered using Apache Maven Fluido Skin 1.6 +--> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> + <head> + <meta charset="UTF-8" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + <meta name="Date-Revision-yyyymmdd" content="20230504" /> + <meta http-equiv="Content-Language" content="en" /> + <title>Apache Synapse – Apache Synapse - Sample 370</title> + <link rel="stylesheet" href="../../css/apache-maven-fluido-1.6.min.css" /> + <link rel="stylesheet" href="../../css/site.css" /> + <link rel="stylesheet" href="../../css/print.css" media="print" /> + <script type="text/javascript" src="../../js/apache-maven-fluido-1.6.min.js"></script> + </head> + <body class="topBarDisabled"> + <div class="container-fluid"> + <div id="banner"> + <div class="pull-left"><div id="bannerLeft"><h2>Apache Synapse</h2> +</div> +</div> + <div class="pull-right"></div> + <div class="clear"><hr/></div> + </div> + + <div id="breadcrumbs"> + <ul class="breadcrumb"> + <li id="publishDate">Last Published: 2023-05-04<span class="divider">|</span> +</li> + <li id="projectVersion">Version: 3.0.2</li> + </ul> + </div> + <div class="row-fluid"> + <div id="leftColumn" class="span2"> + <div class="well sidebar-nav"> +<ul class="nav nav-list"> + <li class="nav-header">Main Menu</li> + <li><a href="../../index.html" title="Home"><span class="none"></span>Home</a> </li> + <li><a href="../../download.html" title="Download"><span class="none"></span>Download</a> </li> + <li><a href="../../history.html" title="History"><span class="none"></span>History</a> </li> + <li><a href="http://www.apache.org/licenses/LICENSE-2.0" class="externalLink" title="License"><span class="none"></span>License</a> </li> + <li><a href="http://www.apache.org/foundation/thanks.html" class="externalLink" title="Thanks"><span class="none"></span>Thanks</a> </li> + <li><a href="http://www.apache.org/foundation/sponsorship.html" class="externalLink" title="Sponsorship"><span class="none"></span>Sponsorship</a> </li> + <li><a href="http://www.apache.org/security/" class="externalLink" title="Security"><span class="none"></span>Security</a> </li> + <li class="nav-header">Documentation</li> + <li><a href="../../userguide/installation.html" title="Installation Guide"><span class="none"></span>Installation Guide</a> </li> + <li><a href="../../userguide/quick_start.html" title="Quick Start Guide"><span class="none"></span>Quick Start Guide</a> </li> + <li><a href="../../userguide/samples/setup/index.html" title="Samples Setup Guide"><span class="none"></span>Samples Setup Guide</a> </li> + <li><a href="../../userguide/samples.html" title="Samples Catalog"><span class="none"></span>Samples Catalog</a> </li> + <li><a href="../../userguide/config.html" title="Configuration Language"><span class="none"></span>Configuration Language</a> </li> + <li><a href="../../userguide/mediators.html" title="Mediators Catalog"><span class="none"></span>Mediators Catalog</a> </li> + <li><a href="../../userguide/transports.html" title="Transports Catalog"><span class="none"></span>Transports Catalog</a> </li> + <li><a href="../../userguide/properties.html" title="Properties Catalog"><span class="none"></span>Properties Catalog</a> </li> + <li><a href="../../userguide/xpath.html" title="XPath functions and Variables"><span class="none"></span>XPath functions and Variables</a> </li> + <li><a href="../../userguide/extending.html" title="Extending Synapse"><span class="none"></span>Extending Synapse</a> </li> + <li><a href="../../userguide/template_library.html" title="Synapse Template Libraries"><span class="none"></span>Synapse Template Libraries</a> </li> + <li><a href="../../userguide/upgrading.html" title="Upgrading"><span class="none"></span>Upgrading</a> </li> + <li><a href="../../userguide/deployment.html" title="Deployment"><span class="none"></span>Deployment</a> </li> + <li><a href="../../apidocs/" title="Javadocs"><span class="none"></span>Javadocs</a> </li> + <li><a href="../../userguide/faq.html" title="FAQ"><span class="none"></span>FAQ</a> </li> + <li class="nav-header">Developer Resources</li> + <li><a href="../../dev/developer-guide.html" title="Developer Guide"><span class="none"></span>Developer Guide</a> </li> + <li><a href="../../dev/best-practices.html" title="Development Best Practices"><span class="none"></span>Development Best Practices</a> </li> + <li><a href="../../dev/release-process.html" title="Release Process"><span class="none"></span>Release Process</a> </li> + <li class="nav-header">Project Details</li> + <li><a href="../../project-info.html" title="Overview"><span class="none"></span>Overview</a> </li> + <li><a href="../../mail-lists.html" title="Mailing Lists"><span class="none"></span>Mailing Lists</a> </li> + <li><a href="../../source-repository.html" title="Source Repository"><span class="none"></span>Source Repository</a> </li> + <li><a href="../../issue-tracking.html" title="Issue Tracking"><span class="none"></span>Issue Tracking</a> </li> + <li><a href="../../dependency-management.html" title="Dependencies"><span class="none"></span>Dependencies</a> </li> + <li><a href="../../team-list.html" title="Project Team"><span class="none"></span>Project Team</a> </li> + </ul> + <hr /> + <div id="poweredBy"> + <div class="clear"></div> + <div class="clear"></div> + <div class="clear"></div> + <div class="clear"></div> + <a href="http://maven.apache.org/" title="Built by Maven" class="poweredBy"><img class="builtBy" alt="Built by Maven" src="../../images/logos/maven-feather.png" /></a> + </div> + </div> + </div> + <div id="bodyColumn" class="span10" > + + + <div class="section"> +<h2><a name="Sample_370:_Introduction_to_Throttle_Mediator_and_Concurrency_Throttling"></a>Sample 370: Introduction to Throttle Mediator and Concurrency Throttling</h2> + +<div class="xmlConf"><definitions xmlns="http://ws.apache.org/ns/synapse"> + + <sequence name="main"> + <in> + <throttle id="A"> + <policy> + <!-- define throttle policy --> + <wsp:Policy xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" + xmlns:throttle="http://www.wso2.org/products/wso2commons/throttle"> + <throttle:ThrottleAssertion> + <throttle:MaximumConcurrentAccess>10</throttle:MaximumConcurrentAccess> + </throttle:ThrottleAssertion> + </wsp:Policy> + </policy> + <onAccept> + <log level="custom"> + <property name="text" value="**Access Accept**"/> + </log> + <send> + <endpoint> + <address uri="http://localhost:9000/services/SimpleStockQuoteService"/> + </endpoint> + </send> + </onAccept> + <onReject> + <log level="custom"> + <property name="text" value="**Access Denied**"/> + </log> + <makefault response="true"> + <code xmlns:tns="http://www.w3.org/2003/05/soap-envelope" + value="tns:Receiver"/> + <reason value="**Access Denied**"/> + </makefault> + <send/> + <drop/> + </onReject> + </throttle> + </in> + <out> + <throttle id="A"/> + <send/> + </out> + </sequence> + +</definitions></div> + +<div class="section"> +<h3><a name="Objective"></a>Objective</h3> + +<p> + Showcase the ability of Synapse to throttle incoming requests based on the + concurrency level + </p> + </div> + +<div class="section"> +<h3><a name="Pre-requisites"></a>Pre-requisites</h3> + +<p> + </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> + + </div> + +<div class="section"> +<h3><a name="Executing_the_Client"></a>Executing the Client</h3> + +<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> + </div> + </div> + +<p><a href="../samples.html">Back to Catalog</a></p> + + + </div> + </div> + </div> + <hr/> + <footer> + <div class="container-fluid"> + <div class="row-fluid"> + <p>Copyright ©2005–2023 +<a href="http://www.apache.org/">Apache Software Foundation</a>. +All rights reserved.</p> + </div> + </div> + </footer> + </body> +</html> Added: synapse/site/3_0_2/userguide/samples/sample371.html URL: http://svn.apache.org/viewvc/synapse/site/3_0_2/userguide/samples/sample371.html?rev=1909775&view=auto ============================================================================== --- synapse/site/3_0_2/userguide/samples/sample371.html (added) +++ synapse/site/3_0_2/userguide/samples/sample371.html Fri May 12 16:09:34 2023 @@ -0,0 +1,276 @@ +<!DOCTYPE html> +<!-- + | Generated by Apache Maven Doxia Site Renderer 1.7.4 at 2023-05-04 + | Rendered using Apache Maven Fluido Skin 1.6 +--> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> + <head> + <meta charset="UTF-8" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + <meta name="Date-Revision-yyyymmdd" content="20230504" /> + <meta http-equiv="Content-Language" content="en" /> + <title>Apache Synapse – Apache Synapse - Sample 371</title> + <link rel="stylesheet" href="../../css/apache-maven-fluido-1.6.min.css" /> + <link rel="stylesheet" href="../../css/site.css" /> + <link rel="stylesheet" href="../../css/print.css" media="print" /> + <script type="text/javascript" src="../../js/apache-maven-fluido-1.6.min.js"></script> + </head> + <body class="topBarDisabled"> + <div class="container-fluid"> + <div id="banner"> + <div class="pull-left"><div id="bannerLeft"><h2>Apache Synapse</h2> +</div> +</div> + <div class="pull-right"></div> + <div class="clear"><hr/></div> + </div> + + <div id="breadcrumbs"> + <ul class="breadcrumb"> + <li id="publishDate">Last Published: 2023-05-04<span class="divider">|</span> +</li> + <li id="projectVersion">Version: 3.0.2</li> + </ul> + </div> + <div class="row-fluid"> + <div id="leftColumn" class="span2"> + <div class="well sidebar-nav"> +<ul class="nav nav-list"> + <li class="nav-header">Main Menu</li> + <li><a href="../../index.html" title="Home"><span class="none"></span>Home</a> </li> + <li><a href="../../download.html" title="Download"><span class="none"></span>Download</a> </li> + <li><a href="../../history.html" title="History"><span class="none"></span>History</a> </li> + <li><a href="http://www.apache.org/licenses/LICENSE-2.0" class="externalLink" title="License"><span class="none"></span>License</a> </li> + <li><a href="http://www.apache.org/foundation/thanks.html" class="externalLink" title="Thanks"><span class="none"></span>Thanks</a> </li> + <li><a href="http://www.apache.org/foundation/sponsorship.html" class="externalLink" title="Sponsorship"><span class="none"></span>Sponsorship</a> </li> + <li><a href="http://www.apache.org/security/" class="externalLink" title="Security"><span class="none"></span>Security</a> </li> + <li class="nav-header">Documentation</li> + <li><a href="../../userguide/installation.html" title="Installation Guide"><span class="none"></span>Installation Guide</a> </li> + <li><a href="../../userguide/quick_start.html" title="Quick Start Guide"><span class="none"></span>Quick Start Guide</a> </li> + <li><a href="../../userguide/samples/setup/index.html" title="Samples Setup Guide"><span class="none"></span>Samples Setup Guide</a> </li> + <li><a href="../../userguide/samples.html" title="Samples Catalog"><span class="none"></span>Samples Catalog</a> </li> + <li><a href="../../userguide/config.html" title="Configuration Language"><span class="none"></span>Configuration Language</a> </li> + <li><a href="../../userguide/mediators.html" title="Mediators Catalog"><span class="none"></span>Mediators Catalog</a> </li> + <li><a href="../../userguide/transports.html" title="Transports Catalog"><span class="none"></span>Transports Catalog</a> </li> + <li><a href="../../userguide/properties.html" title="Properties Catalog"><span class="none"></span>Properties Catalog</a> </li> + <li><a href="../../userguide/xpath.html" title="XPath functions and Variables"><span class="none"></span>XPath functions and Variables</a> </li> + <li><a href="../../userguide/extending.html" title="Extending Synapse"><span class="none"></span>Extending Synapse</a> </li> + <li><a href="../../userguide/template_library.html" title="Synapse Template Libraries"><span class="none"></span>Synapse Template Libraries</a> </li> + <li><a href="../../userguide/upgrading.html" title="Upgrading"><span class="none"></span>Upgrading</a> </li> + <li><a href="../../userguide/deployment.html" title="Deployment"><span class="none"></span>Deployment</a> </li> + <li><a href="../../apidocs/" title="Javadocs"><span class="none"></span>Javadocs</a> </li> + <li><a href="../../userguide/faq.html" title="FAQ"><span class="none"></span>FAQ</a> </li> + <li class="nav-header">Developer Resources</li> + <li><a href="../../dev/developer-guide.html" title="Developer Guide"><span class="none"></span>Developer Guide</a> </li> + <li><a href="../../dev/best-practices.html" title="Development Best Practices"><span class="none"></span>Development Best Practices</a> </li> + <li><a href="../../dev/release-process.html" title="Release Process"><span class="none"></span>Release Process</a> </li> + <li class="nav-header">Project Details</li> + <li><a href="../../project-info.html" title="Overview"><span class="none"></span>Overview</a> </li> + <li><a href="../../mail-lists.html" title="Mailing Lists"><span class="none"></span>Mailing Lists</a> </li> + <li><a href="../../source-repository.html" title="Source Repository"><span class="none"></span>Source Repository</a> </li> + <li><a href="../../issue-tracking.html" title="Issue Tracking"><span class="none"></span>Issue Tracking</a> </li> + <li><a href="../../dependency-management.html" title="Dependencies"><span class="none"></span>Dependencies</a> </li> + <li><a href="../../team-list.html" title="Project Team"><span class="none"></span>Project Team</a> </li> + </ul> + <hr /> + <div id="poweredBy"> + <div class="clear"></div> + <div class="clear"></div> + <div class="clear"></div> + <div class="clear"></div> + <a href="http://maven.apache.org/" title="Built by Maven" class="poweredBy"><img class="builtBy" alt="Built by Maven" src="../../images/logos/maven-feather.png" /></a> + </div> + </div> + </div> + <div id="bodyColumn" class="span10" > + + + <div class="section"> +<h2><a name="Sample_371:_Restricting_Requests_Based_on_Policies"></a>Sample 371: Restricting Requests Based on Policies</h2> + +<div class="xmlConf"><definitions xmlns="http://ws.apache.org/ns/synapse"> + + <sequence name="main"> + <in> + <throttle id="A"> + <policy> + <!-- define throttle policy --> + <wsp:Policy xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" + xmlns:throttle="http://www.wso2.org/products/wso2commons/throttle"> + <throttle:ThrottleAssertion> + <wsp:All> + <throttle:ID throttle:type="IP">other</throttle:ID> + <wsp:ExactlyOne> + <wsp:All> + <throttle:MaximumCount>4</throttle:MaximumCount> + <throttle:UnitTime>800000</throttle:UnitTime> + <throttle:ProhibitTimePeriod wsp:Optional="true">10000 + </throttle:ProhibitTimePeriod> + </wsp:All> + <throttle:IsAllow>true</throttle:IsAllow> + </wsp:ExactlyOne> + </wsp:All> + <wsp:All> + <throttle:ID throttle:type="IP">192.168.8.200-192.168.8.222 + </throttle:ID> + <wsp:ExactlyOne> + <wsp:All> + <throttle:MaximumCount>8</throttle:MaximumCount> + <throttle:UnitTime>800000</throttle:UnitTime> + <throttle:ProhibitTimePeriod wsp:Optional="true">10 + </throttle:ProhibitTimePeriod> + </wsp:All> + <throttle:IsAllow>true</throttle:IsAllow> + </wsp:ExactlyOne> + </wsp:All> + <wsp:All> + <throttle:ID throttle:type="IP">192.168.8.201</throttle:ID> + <wsp:ExactlyOne> + <wsp:All> + <throttle:MaximumCount>200</throttle:MaximumCount> + <throttle:UnitTime>600000</throttle:UnitTime> + <throttle:ProhibitTimePeriod wsp:Optional="true"/> + </wsp:All> + <throttle:IsAllow>true</throttle:IsAllow> + </wsp:ExactlyOne> + </wsp:All> + <wsp:All> + <throttle:ID throttle:type="IP">192.168.8.198</throttle:ID> + <wsp:ExactlyOne> + <wsp:All> + <throttle:MaximumCount>50</throttle:MaximumCount> + <throttle:UnitTime>500000</throttle:UnitTime> + <throttle:ProhibitTimePeriod wsp:Optional="true"/> + </wsp:All> + <throttle:IsAllow>true</throttle:IsAllow> + </wsp:ExactlyOne> + </wsp:All> + </throttle:ThrottleAssertion> + </wsp:Policy> + </policy> + <onAccept> + <log level="custom"> + <property name="text" value="**Access Accept**"/> + </log> + <send> + <endpoint> + <address uri="http://localhost:9000/services/SimpleStockQuoteService"/> + </endpoint> + </send> + </onAccept> + <onReject> + <log level="custom"> + <property name="text" value="**Access Denied**"/> + </log> + <makefault response="true"> + <code xmlns:tns="http://www.w3.org/2003/05/soap-envelope" + value="tns:Receiver"/> + <reason value="**Access Denied**"/> + </makefault> + <send/> + <drop/> + </onReject> + </throttle> + </in> + <out> + <throttle id="A"/> + <send/> + </out> + </sequence> + +</definitions></div> + +<div class="section"> +<h3><a name="Objective"></a>Objective</h3> + +<p> + Demonstrate how to throttle incoming requests based on complex policies + </p> + </div> + +<div class="section"> +<h3><a name="Pre-requisites"></a>Pre-requisites</h3> + +<p> + </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> + + </div> + +<div class="section"> +<h3><a name="Executing_the_Client"></a>Executing the Client</h3> + +<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> + </div> + </div> + +<p><a href="../samples.html">Back to Catalog</a></p> + + + </div> + </div> + </div> + <hr/> + <footer> + <div class="container-fluid"> + <div class="row-fluid"> + <p>Copyright ©2005–2023 +<a href="http://www.apache.org/">Apache Software Foundation</a>. +All rights reserved.</p> + </div> + </div> + </footer> + </body> +</html> Added: synapse/site/3_0_2/userguide/samples/sample372.html URL: http://svn.apache.org/viewvc/synapse/site/3_0_2/userguide/samples/sample372.html?rev=1909775&view=auto ============================================================================== --- synapse/site/3_0_2/userguide/samples/sample372.html (added) +++ synapse/site/3_0_2/userguide/samples/sample372.html Fri May 12 16:09:34 2023 @@ -0,0 +1,215 @@ +<!DOCTYPE html> +<!-- + | Generated by Apache Maven Doxia Site Renderer 1.7.4 at 2023-05-04 + | Rendered using Apache Maven Fluido Skin 1.6 +--> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> + <head> + <meta charset="UTF-8" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + <meta name="Date-Revision-yyyymmdd" content="20230504" /> + <meta http-equiv="Content-Language" content="en" /> + <title>Apache Synapse – Apache Synapse - Sample 372</title> + <link rel="stylesheet" href="../../css/apache-maven-fluido-1.6.min.css" /> + <link rel="stylesheet" href="../../css/site.css" /> + <link rel="stylesheet" href="../../css/print.css" media="print" /> + <script type="text/javascript" src="../../js/apache-maven-fluido-1.6.min.js"></script> + </head> + <body class="topBarDisabled"> + <div class="container-fluid"> + <div id="banner"> + <div class="pull-left"><div id="bannerLeft"><h2>Apache Synapse</h2> +</div> +</div> + <div class="pull-right"></div> + <div class="clear"><hr/></div> + </div> + + <div id="breadcrumbs"> + <ul class="breadcrumb"> + <li id="publishDate">Last Published: 2023-05-04<span class="divider">|</span> +</li> + <li id="projectVersion">Version: 3.0.2</li> + </ul> + </div> + <div class="row-fluid"> + <div id="leftColumn" class="span2"> + <div class="well sidebar-nav"> +<ul class="nav nav-list"> + <li class="nav-header">Main Menu</li> + <li><a href="../../index.html" title="Home"><span class="none"></span>Home</a> </li> + <li><a href="../../download.html" title="Download"><span class="none"></span>Download</a> </li> + <li><a href="../../history.html" title="History"><span class="none"></span>History</a> </li> + <li><a href="http://www.apache.org/licenses/LICENSE-2.0" class="externalLink" title="License"><span class="none"></span>License</a> </li> + <li><a href="http://www.apache.org/foundation/thanks.html" class="externalLink" title="Thanks"><span class="none"></span>Thanks</a> </li> + <li><a href="http://www.apache.org/foundation/sponsorship.html" class="externalLink" title="Sponsorship"><span class="none"></span>Sponsorship</a> </li> + <li><a href="http://www.apache.org/security/" class="externalLink" title="Security"><span class="none"></span>Security</a> </li> + <li class="nav-header">Documentation</li> + <li><a href="../../userguide/installation.html" title="Installation Guide"><span class="none"></span>Installation Guide</a> </li> + <li><a href="../../userguide/quick_start.html" title="Quick Start Guide"><span class="none"></span>Quick Start Guide</a> </li> + <li><a href="../../userguide/samples/setup/index.html" title="Samples Setup Guide"><span class="none"></span>Samples Setup Guide</a> </li> + <li><a href="../../userguide/samples.html" title="Samples Catalog"><span class="none"></span>Samples Catalog</a> </li> + <li><a href="../../userguide/config.html" title="Configuration Language"><span class="none"></span>Configuration Language</a> </li> + <li><a href="../../userguide/mediators.html" title="Mediators Catalog"><span class="none"></span>Mediators Catalog</a> </li> + <li><a href="../../userguide/transports.html" title="Transports Catalog"><span class="none"></span>Transports Catalog</a> </li> + <li><a href="../../userguide/properties.html" title="Properties Catalog"><span class="none"></span>Properties Catalog</a> </li> + <li><a href="../../userguide/xpath.html" title="XPath functions and Variables"><span class="none"></span>XPath functions and Variables</a> </li> + <li><a href="../../userguide/extending.html" title="Extending Synapse"><span class="none"></span>Extending Synapse</a> </li> + <li><a href="../../userguide/template_library.html" title="Synapse Template Libraries"><span class="none"></span>Synapse Template Libraries</a> </li> + <li><a href="../../userguide/upgrading.html" title="Upgrading"><span class="none"></span>Upgrading</a> </li> + <li><a href="../../userguide/deployment.html" title="Deployment"><span class="none"></span>Deployment</a> </li> + <li><a href="../../apidocs/" title="Javadocs"><span class="none"></span>Javadocs</a> </li> + <li><a href="../../userguide/faq.html" title="FAQ"><span class="none"></span>FAQ</a> </li> + <li class="nav-header">Developer Resources</li> + <li><a href="../../dev/developer-guide.html" title="Developer Guide"><span class="none"></span>Developer Guide</a> </li> + <li><a href="../../dev/best-practices.html" title="Development Best Practices"><span class="none"></span>Development Best Practices</a> </li> + <li><a href="../../dev/release-process.html" title="Release Process"><span class="none"></span>Release Process</a> </li> + <li class="nav-header">Project Details</li> + <li><a href="../../project-info.html" title="Overview"><span class="none"></span>Overview</a> </li> + <li><a href="../../mail-lists.html" title="Mailing Lists"><span class="none"></span>Mailing Lists</a> </li> + <li><a href="../../source-repository.html" title="Source Repository"><span class="none"></span>Source Repository</a> </li> + <li><a href="../../issue-tracking.html" title="Issue Tracking"><span class="none"></span>Issue Tracking</a> </li> + <li><a href="../../dependency-management.html" title="Dependencies"><span class="none"></span>Dependencies</a> </li> + <li><a href="../../team-list.html" title="Project Team"><span class="none"></span>Project Team</a> </li> + </ul> + <hr /> + <div id="poweredBy"> + <div class="clear"></div> + <div class="clear"></div> + <div class="clear"></div> + <div class="clear"></div> + <a href="http://maven.apache.org/" title="Built by Maven" class="poweredBy"><img class="builtBy" alt="Built by Maven" src="../../images/logos/maven-feather.png" /></a> + </div> + </div> + </div> + <div id="bodyColumn" class="span10" > + + + <div class="section"> +<h2><a name="Sample_372:_Use_of_Concurrency_Throttling_and_Request_Rate_Based_Throttling"></a>Sample 372: Use of Concurrency Throttling and Request Rate Based Throttling</h2> + +<div class="xmlConf"><definitions xmlns="http://ws.apache.org/ns/synapse"> + + <registry provider="org.apache.synapse.registry.url.SimpleURLRegistry"> + <!-- the root property of the simple URL registry helps resolve a resource URL as root + key --> + <parameter name="root">file:repository/</parameter> + <!-- all resources loaded from the URL registry would be cached for this number of milli seconds --> + <parameter name="cachableDuration">150000</parameter> + </registry> + + <sequence name="onAcceptSequence"> + <log level="custom"> + <property name="text" value="**Access Accept**"/> + </log> + <send> + <endpoint> + <address uri="http://localhost:9000/services/SimpleStockQuoteService"/> + </endpoint> + </send> + </sequence> + + <sequence name="onRejectSequence" trace="enable"> + <log level="custom"> + <property name="text" value="**Access Denied**"/> + </log> + <makefault response="true"> + <code xmlns:tns="http://www.w3.org/2003/05/soap-envelope" value="tns:Receiver"/> + <reason value="**Access Denied**"/> + </makefault> + <send/> + <drop/> + </sequence> + + <proxy name="StockQuoteProxy"> + <target> + <inSequence> + <throttle onReject="onRejectSequence" onAccept="onAcceptSequence" id="A"> + <policy key="conf/sample/resources/policy/throttle_policy.xml"/> + </throttle> + </inSequence> + <outSequence> + <throttle id="A"/> + <send/> + </outSequence> + </target> + <publishWSDL uri="file:repository/conf/sample/resources/proxy/sample_proxy_1.wsdl"/> + </proxy> + +</definitions></div> + +<div class="section"> +<h3><a name="Objective"></a>Objective</h3> + +<p> + Showcase how to use the concurrency throttling in conjunction with request rate + throttling + </p> + </div> + +<div class="section"> +<h3><a name="Pre-requisites"></a>Pre-requisites</h3> + +<p> + </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> + + </div> + +<div class="section"> +<h3><a name="Executing_the_Client"></a>Executing the Client</h3> + +<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> + </div> + </div> + +<p><a href="../samples.html">Back to Catalog</a></p> + + + </div> + </div> + </div> + <hr/> + <footer> + <div class="container-fluid"> + <div class="row-fluid"> + <p>Copyright ©2005–2023 +<a href="http://www.apache.org/">Apache Software Foundation</a>. +All rights reserved.</p> + </div> + </div> + </footer> + </body> +</html> Added: synapse/site/3_0_2/userguide/samples/sample380.html URL: http://svn.apache.org/viewvc/synapse/site/3_0_2/userguide/samples/sample380.html?rev=1909775&view=auto ============================================================================== --- synapse/site/3_0_2/userguide/samples/sample380.html (added) +++ synapse/site/3_0_2/userguide/samples/sample380.html Fri May 12 16:09:34 2023 @@ -0,0 +1,305 @@ +<!DOCTYPE html> +<!-- + | Generated by Apache Maven Doxia Site Renderer 1.7.4 at 2023-05-04 + | Rendered using Apache Maven Fluido Skin 1.6 +--> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> + <head> + <meta charset="UTF-8" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + <meta name="Date-Revision-yyyymmdd" content="20230504" /> + <meta http-equiv="Content-Language" content="en" /> + <title>Apache Synapse – Apache Synapse - Sample 380</title> + <link rel="stylesheet" href="../../css/apache-maven-fluido-1.6.min.css" /> + <link rel="stylesheet" href="../../css/site.css" /> + <link rel="stylesheet" href="../../css/print.css" media="print" /> + <script type="text/javascript" src="../../js/apache-maven-fluido-1.6.min.js"></script> + </head> + <body class="topBarDisabled"> + <div class="container-fluid"> + <div id="banner"> + <div class="pull-left"><div id="bannerLeft"><h2>Apache Synapse</h2> +</div> +</div> + <div class="pull-right"></div> + <div class="clear"><hr/></div> + </div> + + <div id="breadcrumbs"> + <ul class="breadcrumb"> + <li id="publishDate">Last Published: 2023-05-04<span class="divider">|</span> +</li> + <li id="projectVersion">Version: 3.0.2</li> + </ul> + </div> + <div class="row-fluid"> + <div id="leftColumn" class="span2"> + <div class="well sidebar-nav"> +<ul class="nav nav-list"> + <li class="nav-header">Main Menu</li> + <li><a href="../../index.html" title="Home"><span class="none"></span>Home</a> </li> + <li><a href="../../download.html" title="Download"><span class="none"></span>Download</a> </li> + <li><a href="../../history.html" title="History"><span class="none"></span>History</a> </li> + <li><a href="http://www.apache.org/licenses/LICENSE-2.0" class="externalLink" title="License"><span class="none"></span>License</a> </li> + <li><a href="http://www.apache.org/foundation/thanks.html" class="externalLink" title="Thanks"><span class="none"></span>Thanks</a> </li> + <li><a href="http://www.apache.org/foundation/sponsorship.html" class="externalLink" title="Sponsorship"><span class="none"></span>Sponsorship</a> </li> + <li><a href="http://www.apache.org/security/" class="externalLink" title="Security"><span class="none"></span>Security</a> </li> + <li class="nav-header">Documentation</li> + <li><a href="../../userguide/installation.html" title="Installation Guide"><span class="none"></span>Installation Guide</a> </li> + <li><a href="../../userguide/quick_start.html" title="Quick Start Guide"><span class="none"></span>Quick Start Guide</a> </li> + <li><a href="../../userguide/samples/setup/index.html" title="Samples Setup Guide"><span class="none"></span>Samples Setup Guide</a> </li> + <li><a href="../../userguide/samples.html" title="Samples Catalog"><span class="none"></span>Samples Catalog</a> </li> + <li><a href="../../userguide/config.html" title="Configuration Language"><span class="none"></span>Configuration Language</a> </li> + <li><a href="../../userguide/mediators.html" title="Mediators Catalog"><span class="none"></span>Mediators Catalog</a> </li> + <li><a href="../../userguide/transports.html" title="Transports Catalog"><span class="none"></span>Transports Catalog</a> </li> + <li><a href="../../userguide/properties.html" title="Properties Catalog"><span class="none"></span>Properties Catalog</a> </li> + <li><a href="../../userguide/xpath.html" title="XPath functions and Variables"><span class="none"></span>XPath functions and Variables</a> </li> + <li><a href="../../userguide/extending.html" title="Extending Synapse"><span class="none"></span>Extending Synapse</a> </li> + <li><a href="../../userguide/template_library.html" title="Synapse Template Libraries"><span class="none"></span>Synapse Template Libraries</a> </li> + <li><a href="../../userguide/upgrading.html" title="Upgrading"><span class="none"></span>Upgrading</a> </li> + <li><a href="../../userguide/deployment.html" title="Deployment"><span class="none"></span>Deployment</a> </li> + <li><a href="../../apidocs/" title="Javadocs"><span class="none"></span>Javadocs</a> </li> + <li><a href="../../userguide/faq.html" title="FAQ"><span class="none"></span>FAQ</a> </li> + <li class="nav-header">Developer Resources</li> + <li><a href="../../dev/developer-guide.html" title="Developer Guide"><span class="none"></span>Developer Guide</a> </li> + <li><a href="../../dev/best-practices.html" title="Development Best Practices"><span class="none"></span>Development Best Practices</a> </li> + <li><a href="../../dev/release-process.html" title="Release Process"><span class="none"></span>Release Process</a> </li> + <li class="nav-header">Project Details</li> + <li><a href="../../project-info.html" title="Overview"><span class="none"></span>Overview</a> </li> + <li><a href="../../mail-lists.html" title="Mailing Lists"><span class="none"></span>Mailing Lists</a> </li> + <li><a href="../../source-repository.html" title="Source Repository"><span class="none"></span>Source Repository</a> </li> + <li><a href="../../issue-tracking.html" title="Issue Tracking"><span class="none"></span>Issue Tracking</a> </li> + <li><a href="../../dependency-management.html" title="Dependencies"><span class="none"></span>Dependencies</a> </li> + <li><a href="../../team-list.html" title="Project Team"><span class="none"></span>Project Team</a> </li> + </ul> + <hr /> + <div id="poweredBy"> + <div class="clear"></div> + <div class="clear"></div> + <div class="clear"></div> + <div class="clear"></div> + <a href="http://maven.apache.org/" title="Built by Maven" class="poweredBy"><img class="builtBy" alt="Built by Maven" src="../../images/logos/maven-feather.png" /></a> + </div> + </div> + </div> + <div id="bodyColumn" class="span10" > + + + <div class="section"> +<h2><a name="Sample_380:_Writing_Custom_Mediation_Logic_in_Java"></a>Sample 380: Writing Custom Mediation Logic in Java</h2> + +<div class="xmlConf"><definitions xmlns="http://ws.apache.org/ns/synapse"> + + <sequence name="fault"> + <makefault> + <code xmlns:tns="http://www.w3.org/2003/05/soap-envelope" value="tns:Receiver"/> + <reason value="Mediation failed."/> + </makefault> + <send/> + </sequence> + + <sequence name="main" onError="fault"> + <in> + <send> + <endpoint name="stockquote"> + <address uri="http://localhost:9000/services/SimpleStockQuoteService"/> + </endpoint> + </send> + </in> + <out> + <class name="samples.mediators.DiscountQuoteMediator"> + <property name="discountFactor" value="10"/> + <property name="bonusFor" value="5"/> + </class> + <send/> + </out> + </sequence> + +</definitions></div> + +<div class="section"> +<h3><a name="Objective"></a>Objective</h3> + +<p> + Demonstrate the use of class mediator to extend the mediation functionality of + Synapse + </p> + </div> + +<div class="section"> +<h3><a name="Pre-requisites"></a>Pre-requisites</h3> + +<p> + </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> + + </div> + +<div class="section"> +<h3><a name="Executing_the_Client"></a>Executing the Client</h3> + +<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="10"; + + private String bonusFor="10"; + + private int bonusCount=0; + + public DiscountQuoteMediator(){} + + public boolean mediate(MessageContext mc) { + + String price= mc.getEnvelope().getBody().getFirstElement().getFirstElement(). + getFirstChildWithName(new QName("http://services.samples","last")).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 <= bonusNo) { + lastPrice = new Double(lastPrice.doubleValue() - lastPrice.doubleValue() * 0.05); + bonusCount++; + } + + String discountedPrice = lastPrice.toString(); + + mc.getEnvelope().getBody().getFirstElement().getFirstElement().getFirstChildWithName + (new QName("http://services.samples","last")).setText(discountedPrice); + + System.out.println("Quote value discounted."); + System.out.println("Original price: " + price); + System.out.println("Discounted price: " + 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> + </div> + </div> + +<p><a href="../samples.html">Back to Catalog</a></p> + + + </div> + </div> + </div> + <hr/> + <footer> + <div class="container-fluid"> + <div class="row-fluid"> + <p>Copyright ©2005–2023 +<a href="http://www.apache.org/">Apache Software Foundation</a>. +All rights reserved.</p> + </div> + </div> + </footer> + </body> +</html>
