Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Info

You can also specify the throttle policy within a proxy service configuration as a key by saving the policy in the registry or by saving it as a local entry. However, when you are not using the Management Console, you are required to manually create an entry in the <ESB_HOME/repository/deployment/server/servicemetafiles/<Service_Name>.xml file to enable throttling as shown in the example below.

Code Block
languagexml
<?xml version="1.0" encoding="UTF-8"?>
<serviceGroup name="ThrottleProxy" successfullyAdded="true">
   <service name="ThrottleProxy"
            exposedAllTransports="false"
            serviceDeployedTime="1431430083400"
            successfullyAdded="true">
      <operation name="mediate">
         <module name="addressing" version="4.2.0" type="engagedModules"/>
         <module name="POXSecurityModule" version="4.2.2" type="engagedModules"/>
         <module name="wso2statistics" version="4.2.2" type="engagedModules"/>
         <module name="ServerAdminModule" version="4.2.0" type="engagedModules"/>
         <module name="pagination" version="4.2.0" type="engagedModules"/>
      </operation>
      <bindings>
         <binding name="ThrottleProxySoap12Binding">
            <operation name="mediate"/>
            <operation name="GetMetadata"/>
         </binding>
         <binding name="ThrottleProxySoap11Binding">
            <operation name="mediate"/>
            <operation name="GetMetadata"/>
         </binding>
         <binding name="ThrottleProxyHttpBinding">
            <operation name="mediate"/>
            <operation name="GetMetadata"/>
         </binding>
      </bindings>
      <policies>
         <policy policyType="3">
            <policyUUID>WSO2ServiceThrottlingPolicy</policyUUID>
            <wsp:Policy xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"
                        xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
                        wsu:Id="WSO2ServiceThrottlingPolicy">
               <throttle:ServiceThrottleAssertion xmlns:throttle="http://www.wso2.org/products/wso2commons/throttle">
                  <wsp:Policy>
                     <throttle:ID throttle:type="IP">10.100.0.37</throttle:ID>
                     <wsp:Policy>
                        <throttle:Control>
                           <wsp:Policy>
                              <throttle:MaximumCount>5</throttle:MaximumCount>
                              <throttle:UnitTime>100000</throttle:UnitTime>
                              <throttle:ProhibitTimePeriod wsp:Optional="true">10000</throttle:ProhibitTimePeriod>
                           </wsp:Policy>
                        </throttle:Control>
                     </wsp:Policy>
                  </wsp:Policy>
                  <wsp:Policy>
                     <throttle:ID throttle:type="DOMAIN">localhost</throttle:ID>
                     <wsp:Policy>
                        <throttle:Control>
                           <wsp:Policy>
                              <throttle:MaximumCount>1</throttle:MaximumCount>
                              <throttle:UnitTime>10000</throttle:UnitTime>
                              <throttle:ProhibitTimePeriod wsp:Optional="true">10000</throttle:ProhibitTimePeriod>
                           </wsp:Policy>
                        </throttle:Control>
                     </wsp:Policy>
                  </wsp:Policy>
                  <wsp:Policy>
                     <throttle:ID throttle:type="IP">127.0.0.1</throttle:ID>
                     <wsp:Policy>
                        <throttle:Control>
                           <wsp:Policy>
                              <throttle:MaximumCount>1</throttle:MaximumCount>
                              <throttle:UnitTime>100000</throttle:UnitTime>
                              <throttle:ProhibitTimePeriod wsp:Optional="true">10000</throttle:ProhibitTimePeriod>
                           </wsp:Policy>
                        </throttle:Control>
                     </wsp:Policy>
                  </wsp:Policy>
               </throttle:ServiceThrottleAssertion>
            </wsp:Policy>
         </policy>
      </policies>
      <module name="addressing" version="4.2.0" type="engagedModules"/>
      <module name="POXSecurityModule" version="4.2.2" type="engagedModules"/>
      <module name="wso2statistics" version="4.2.2" type="engagedModules"/>
      <module name="ServerAdminModule" version="4.2.0" type="engagedModules"/>
      <module name="pagination" version="4.2.0" type="engagedModules"/>
      <parameter name="serviceType" type="1">proxy</parameter>
      <policyUUID>WSO2ServiceThrottlingPolicy</policyUUID>
      <parameter name="disableREST" type="1">true</parameter>
      <module name="wso2throttle" version="4.2.0" type="engagedModules"/>
      <association destinationPath="/repository/transports/https/listener"
                   type="exposedTransports"/>
      <association destinationPath="/repository/transports/http/listener"
                   type="exposedTransports"/>
   </service>
</serviceGroup>

The proxy service configuration in this example can be as follows.

Code Block
languagexml
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="ThrottleProxy"
       transports="https http"
       startOnLoad="true"
       trace="disable">
   <description/>
   <target>
      <endpoint>
         <address uri="http://localhost:9000/services/SimpleStockQuoteService"/>
      </endpoint>
      <inSequence>
         <log level="full"/>
      </inSequence>
   </target>
  <policy key="throttlePolicy1"/>
</proxy>

 The following is an example of a throttle policy configuration that can be saved in the registry or as a local entry.

Code Block
languagexml
<?xml version="1.0" encoding="UTF-8"?>
<localEntry xmlns="http://ws.apache.org/ns/synapse" key="throttlePolicy1">
   <wsp:Policy xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"
               xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
               wsu:Id="WSO2ServiceThrottlingPolicy">
      <throttle:ServiceThrottleAssertion xmlns:throttle="http://www.wso2.org/products/wso2commons/throttle">
         <wsp:Policy>
            <throttle:ID throttle:type="IP">10.100.0.37</throttle:ID>
            <wsp:Policy>
               <throttle:Control>
                  <wsp:Policy>
                     <throttle:MaximumCount>5</throttle:MaximumCount>
                     <throttle:UnitTime>100000</throttle:UnitTime>
                     <throttle:ProhibitTimePeriod wsp:Optional="true">10000</throttle:ProhibitTimePeriod>
                  </wsp:Policy>
               </throttle:Control>
            </wsp:Policy>
         </wsp:Policy>
         <wsp:Policy>
            <throttle:ID throttle:type="DOMAIN">localhost</throttle:ID>
            <wsp:Policy>
               <throttle:Control>
                  <wsp:Policy>
                     <throttle:MaximumCount>5</throttle:MaximumCount>
                     <throttle:UnitTime>100000</throttle:UnitTime>
                     <throttle:ProhibitTimePeriod wsp:Optional="true">10000</throttle:ProhibitTimePeriod>
                  </wsp:Policy>
               </throttle:Control>
            </wsp:Policy>
         </wsp:Policy>
         <wsp:Policy>
            <throttle:ID throttle:type="IP">127.0.0.1</throttle:ID>
            <wsp:Policy>
               <throttle:Control>
                  <wsp:Policy>
                     <throttle:MaximumCount>5</throttle:MaximumCount>
                     <throttle:UnitTime>100000</throttle:UnitTime>
                     <throttle:ProhibitTimePeriod wsp:Optional="true">10000</throttle:ProhibitTimePeriod>
                  </wsp:Policy>
               </throttle:Control>
            </wsp:Policy>
         </wsp:Policy>
      </throttle:ServiceThrottleAssertion>
   </wsp:Policy>
   <description/>
</localEntry>