Sample 372: Use of Concurrency Throttling and Request Rate Based Throttling
<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>
Objective
Showcase how to use the concurrency throttling in conjunction with request rate
throttling
Executing the Client
This is a combination of sample 370 and
sample 371. 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.
Run the client as follows.
ant stockquote -Daddurl=http://localhost:8280/services/StockQuoteProxy
You will get same results as in sample 371. If you
run the load test, results will be different due to the effect of concurrency
throttling.
Back to Catalog