Author: chathura_ce
Date: Tue May 22 02:30:18 2007
New Revision: 540505
URL: http://svn.apache.org/viewvc?view=rev&rev=540505
Log:
Added documentation for throttling sample. Renamed sample names to be
consistent.
Added:
webservices/synapse/trunk/java/repository/conf/sample/synapse_sample_510.xml
- copied, changed from r540429,
webservices/synapse/trunk/java/repository/conf/sample/synapse_sample_600.xml
webservices/synapse/trunk/java/repository/conf/sample/synapse_sample_601.xml
(contents, props changed)
- copied, changed from r540429,
webservices/synapse/trunk/java/repository/conf/sample/synapse_sample_401.xml
Removed:
webservices/synapse/trunk/java/repository/conf/sample/synapse_sample_400.xml
webservices/synapse/trunk/java/repository/conf/sample/synapse_sample_401.xml
Modified:
webservices/synapse/trunk/java/repository/conf/sample/synapse_sample_600.xml
webservices/synapse/trunk/java/src/site/resources/Synapse_Samples.html
Copied:
webservices/synapse/trunk/java/repository/conf/sample/synapse_sample_510.xml
(from r540429,
webservices/synapse/trunk/java/repository/conf/sample/synapse_sample_600.xml)
URL:
http://svn.apache.org/viewvc/webservices/synapse/trunk/java/repository/conf/sample/synapse_sample_510.xml?view=diff&rev=540505&p1=webservices/synapse/trunk/java/repository/conf/sample/synapse_sample_600.xml&r1=540429&p2=webservices/synapse/trunk/java/repository/conf/sample/synapse_sample_510.xml&r2=540505
==============================================================================
(empty)
Modified:
webservices/synapse/trunk/java/repository/conf/sample/synapse_sample_600.xml
URL:
http://svn.apache.org/viewvc/webservices/synapse/trunk/java/repository/conf/sample/synapse_sample_600.xml?view=diff&rev=540505&r1=540504&r2=540505
==============================================================================
---
webservices/synapse/trunk/java/repository/conf/sample/synapse_sample_600.xml
(original)
+++
webservices/synapse/trunk/java/repository/conf/sample/synapse_sample_600.xml
Tue May 22 02:30:18 2007
@@ -16,34 +16,91 @@
~ specific language governing permissions and limitations
~ under the License.
-->
-
-<!-- Demonstrate the use of class mediator -->
-<definitions xmlns="http://ws.apache.org/ns/synapse">
-
- <sequence name="fault">
- <makefault>
- <code value="tns:Receiver"
xmlns:tns="http://www.w3.org/2003/05/soap-envelope"/>
- <reason value="Mediation failed."/>
- </makefault>
- <send/>
- </sequence>
-
- <sequence name="main" onError="fault">
+<definitions xmlns="http://ws.apache.org/ns/synapse"
+ xmlns:throttle="http://ws.apache.org/ns/synapse/throttle">
+ <sequence name="main">
<in>
- <send>
- <endpoint name="stockquote">
- <address
uri="http://localhost:9000/soap/SimpleStockQuoteService"/>
- </endpoint>
- </send>
+ <throttle:throttle>
+ <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"></throttle:ProhibitTimePeriod>
+ </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"></throttle:ProhibitTimePeriod>
+ </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/soap/SimpleStockQuoteService"/>
+ </endpoint>
+ </send>
+ </onAccept>
+ <onReject>
+ <log level="custom">
+ <property name="text" value="**Access Denied**"/>
+ </log>
+ <makefault>
+ <code value="tns:Receiver"
+
xmlns:tns="http://www.w3.org/2003/05/soap-envelope"/>
+ <reason value="**Access Denied**"/>
+ </makefault>
+ <property name="RESPONSE" value="true"/>
+ <header name="To" expression="get-property('ReplyTo')"/>
+ <send/>
+ <drop/>
+ </onReject>
+ </throttle:throttle>
</in>
<out>
- <class name="samples.mediators.DiscountQuoteMediator">
- <property name="discountFactor" value="10"/>
- <property name="bonusFor" value="5"/>
- </class>
<send/>
</out>
</sequence>
-
</definitions>
-
Copied:
webservices/synapse/trunk/java/repository/conf/sample/synapse_sample_601.xml
(from r540429,
webservices/synapse/trunk/java/repository/conf/sample/synapse_sample_401.xml)
URL:
http://svn.apache.org/viewvc/webservices/synapse/trunk/java/repository/conf/sample/synapse_sample_601.xml?view=diff&rev=540505&p1=webservices/synapse/trunk/java/repository/conf/sample/synapse_sample_401.xml&r1=540429&p2=webservices/synapse/trunk/java/repository/conf/sample/synapse_sample_601.xml&r2=540505
==============================================================================
(empty)
Propchange:
webservices/synapse/trunk/java/repository/conf/sample/synapse_sample_601.xml
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/synapse/trunk/java/src/site/resources/Synapse_Samples.html
URL:
http://svn.apache.org/viewvc/webservices/synapse/trunk/java/src/site/resources/Synapse_Samples.html?view=diff&rev=540505&r1=540504&r2=540505
==============================================================================
--- webservices/synapse/trunk/java/src/site/resources/Synapse_Samples.html
(original)
+++ webservices/synapse/trunk/java/src/site/resources/Synapse_Samples.html Tue
May 22 02:30:18 2007
@@ -157,7 +157,8 @@
<li><a href="#Sample51">Sample 51: MTOM and SwA optimizations and
request/response correlation</a></li>
<li><a href="#Sample52">Sample 52: POX to SOAP conversion</a></li>
- <li><a href="#Sample53">Sample 53: Reliable message exchange between
Synapse and the back-end server using WS-ReliableMessaging</a></li>
+ <li><a href="#Sample53">Sample 53: Reliable message exchange between
+ Synapse and the back-end server using WS-ReliableMessaging</a></li>
<li><a href="#Sample54">Sample 54: Load balancing</a></li>
<li><a href="#Sample55">Sample 55: Failover</a></li>
<li><a href="#Sample56">Sample 56: Load balancing with session
@@ -177,7 +178,8 @@
format from SOAP to REST/POX</a></li>
<li><a href="#Sample103">Sample 103: Using WS-Security with policy
attachments for proxy services</a></li>
- <li><a href="#Sample104">Sample 104: Reliable message exchange between
the client and proxy services using WS-ReliableMessaging</a></li>
+ <li><a href="#Sample104">Sample 104: Reliable message exchange between
+ the client and proxy services using WS-ReliableMessaging</a></li>
</ul>
</li>
<li><a href="#Transport">Transport samples</a>
@@ -205,10 +207,16 @@
API methods</a></li>
<li><a href="#Sample503">Sample 503: Using Ruby scripts for
mediation</a></li>
- <li><a href="#Sample600">Sample 600: Class mediator - Writting your own
+ <li><a href="#Sample510">Sample 510: Class mediator - Writting your own
mediation in Java</a></li>
</ul>
</li>
+ <li><a href="#AdvancedMediations">Advanced Mediations</a>
+ <ul>
+ <li><a href="#Sample600">Sample 600: Throttle mediator - Restricting
+ requests based on policies</a></li>
+ </ul>
+ </li>
</ul>
</div>
@@ -1236,7 +1244,7 @@
</out>
</definitions></pre>
-<strong>Objective: Demontrate the message exchange between Synapse and the
+<strong>Objective: Demonstrate the message exchange between Synapse and the
server using WS-ReliableMessaging (WS-RM)</strong>
<p><strong>Pre-Requisites:</strong></p>
@@ -1303,7 +1311,7 @@
</soapenv:Body>
...</pre>
-<p>Once the sequence is estabilished, Synapse sends the request to the server
+<p>Once the sequence is established, Synapse sends the request to the server
with the pre-negotiated sequence ID.</p>
<pre><soapenv:Envelope xmlns:wsa="http://www.w3.org/2005/08/addressing"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
@@ -1327,7 +1335,7 @@
</soapenv:Body>
</soapenv:Envelope></pre>
-<p>Synapse keeps on sending above message till the server reponds with a
+<p>Synapse keeps on sending above message till the server responds with a
valid response message with 200 OK HTTP header. If the server is not ready
with a response, it will respond with 202 Accepted HTTP header for all
requests. Once the server is ready with a response it will send the response
@@ -1355,7 +1363,7 @@
<ns:getQuoteResponse xmlns:ns="http://services.samples/xsd">
...</pre>
-<p>Now both Synase and the server are done with the actual message exchange.
+<p>Now both Synapse and the server are done with the actual message exchange.
Then Synapse sends a request to terminate the sequence as follows:</p>
<pre><soapenv:Envelope xmlns:wsa="http://www.w3.org/2005/08/addressing"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
@@ -1376,8 +1384,8 @@
</soapenv:Body>
</soapenv:Envelope></pre>
-<p>Server reponds to the sequence termination message, accepting to terminate
-the sequence as follows.</p>
+<p>Server responds to the sequence termination message, accepting to
+terminate the sequence as follows.</p>
<pre><soapenv:Envelope xmlns:wsa="http://www.w3.org/2005/08/addressing"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header>
@@ -1399,7 +1407,7 @@
Keep-Alive header is used.</p>
<h2><a name="Sample54">Sample 54:</a></h2>
-<pre><!-- demontrates simple session less load balancing between 3
endpoints -->
+<pre><!-- demonstrates simple session less load balancing between 3
endpoints -->
<definitions xmlns="http://ws.apache.org/ns/synapse">
<sequence name="main" onError="errorHandler">
@@ -2158,8 +2166,8 @@
<enableRM/>
</proxy>
</definitions></pre>
-<strong>Objective: Demontrate the reliable message exchange between the
-client and Synapse using WS-ReliableMessaging (WS-RM)</strong>
+<strong>Objective: Demonstrate the reliable message exchange between the
+client and Synapse using WS-ReliableMessaging (WS-RM)</strong>
<p><strong>Pre-Requisites:</strong></p>
@@ -2179,7 +2187,7 @@
Synapse. Now start the client with WS-RM as follows:</p>
<pre>ant stockquote -Dsymbol=IBM -Dmode=quote
-Daddurl=http://localhost:8081/soap/StockQuoteProxy -Dwsrm=true</pre>
-<p>In this case, client sends WS-RM enabled request to Synase where Synapse
+<p>In this case, client sends WS-RM enabled request to Synapse where Synapse
sends normal request to the server. This can be observed by examining the
wire level messages between the client and Synapse. These messages would be
similar to the wire level messages shown in sample 53. Each message would
@@ -2848,7 +2856,7 @@
<p></p>
-<h2><a name="Sample600">Sample 600</a></h2>
+<h2><a name="Sample510">Sample 510</a></h2>
<p></p>
<pre><!-- Demonstrate the use of class mediator -->
@@ -3020,5 +3028,138 @@
<pre>Quote value discounted.
Original price: 162.30945327447262
Discounted price: 138.77458254967408</pre>
+
+<h1><a name="AdvancedMediations">Advanced mediations</a></h1>
+
+<h2><a name="Sample600">Sample 600</a></h2>
+<pre><definitions xmlns="http://ws.apache.org/ns/synapse"
+ xmlns:throttle="http://ws.apache.org/ns/synapse/throttle">
+ <sequence name="main">
+ <in>
+ <throttle:throttle>
+ <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"></throttle:ProhibitTimePeriod>
+ </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"></throttle:ProhibitTimePeriod>
+ </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/soap/SimpleStockQuoteService"/>
+ </endpoint>
+ </send>
+ </onAccept>
+ <onReject>
+ <log level="custom">
+ <property name="text" value="**Access Denied**"/>
+ </log>
+ <makefault>
+ <code value="tns:Receiver"
+
xmlns:tns="http://www.w3.org/2003/05/soap-envelope"/>
+ <reason value="**Access Denied**"/>
+ </makefault>
+ <property name="RESPONSE" value="true"/>
+ <header name="To"
expression="get-property('ReplyTo')"/>
+ <send/>
+ <drop/>
+ </onReject>
+ </throttle:throttle>
+ </in>
+ <out>
+ <send/>
+ </out>
+ </sequence>
+</definitions></pre>
+<strong>Objective: Demonstrate the use of throttle mediator for restricting
+request counts</strong>
+
+<p><strong>Pre-Requisites:</strong></p>
+
+<p>Deploy the SimpleStockQuoteService in sample Axis2 server and start it on
+port 9000.</p>
+
+<p>Start Synapse with the sample configuration 600 (i.e. synapse -sample
+600).</p>
+
+<p></p>
+
+<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. Policy tag specifies the throttling policy to be applied
+for messages. It contains some IP address ranges and maximum number of
+messages to be allowed for those ranges within the time range 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 below
+command to see how throttling works.</p>
+<pre>ant stockquote -Dsymbol=IBM -Dmode=quote
-Daddurl=http://localhost:8080</pre>
+
+<p>For the first four requests you will get the quote prices for IBM as
+follows:</p>
+<pre>[java] Standard :: Stock price = $177.20143371883802</pre>
+
+<p>You will receive the following response for the fifth request:</p>
+<pre>[java] org.apache.axis2.AxisFault: **Access Denied**</pre>
+
+<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>
+<pre>[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**</pre>
</body>
</html>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]