This is the latest release in the 6.x.x family. For EI 7.0.0, click here.

All docs This doc
Skip to end of metadata
Go to start of metadata

Note that WSO2 EI is shipped with the following changes to what is mentioned in this documentation:

  • <PRODUCT_HOME>/repository/samples/ directory that includes all Integration profile samples is changed to <EI_HOME>/samples/service-bus/.
  • <PRODUCT_HOME>/repository/samples/resources/ directory that includes all artifacts related to the Integration profile samples is changed to <EI_HOME>/samples/service-bus/resources/.

Objective: Demonstrate the use of throttle mediator for restricting request counts

<definitions xmlns="">
    <sequence name="main">
            <throttle id="A">
                    <!-- define throttle policy -->
                    <wsp:Policy xmlns:wsp=""
                                <throttle:ID throttle:type="IP">other</throttle:ID>
                                            <throttle:ProhibitTimePeriod wsp:Optional="true">1000
                                <throttle:ID throttle:type="IP"> -</throttle:ID>
                                            <throttle:ProhibitTimePeriod wsp:Optional="true">100000
                    <log level="custom">
                        <property name="text" value="**Access Accept**"/>
                            <address uri="http://localhost:9000/services/SimpleStockQuoteService"/>
                    <log level="custom">
                        <property name="text" value="**Access Denied**"/>
                        <code value="tns:Receiver"
                        <reason value="**Access Denied**"/>
                    <property name="RESPONSE" value="true"/>
                    <header name="To" action="remove"/>
            <throttle id="A"/>


  • Deploy the SimpleStockQuoteService in sample Axis2 server and start it on port 9000.
  • Create the above configuration and deploy it in the WSO2 EI profile, see Working with WSO2 Integration Studio.

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 to be applied for messages. 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.

ant stockquote -Dsymbol=IBM -Dmode=quote -Daddurl=http://localhost:8280/

For the first four requests you will get the quote prices for IBM as follows.

[java] Standard :: Stock price = $177.20143371883802

You will receive the following response for the fifth request.

[java] org.apache.axis2.AxisFault: **Access Denied**

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 ESB console.

[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** 
  • No labels