This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.

Deploying Custom Throttling Policies

Custom throttling allows system administrators to define dynamic rules for specific use cases. When a custom throttling policy is created, it is possible to define any policy you like. This feature is required when certain traffic thresholds need to be freely throttled or rejected by Data Holders without impacting their performance or availability requirements. For more details on setting the traffic thresholds, refer to Consumer Data Standards - Traffic Thresholds.

In WSO2 Open Banking, the Traffic Manager component of the WSO2 Open Banking API Management module acts as the global throttling engine. This is based on the same technology as WSO2 Complex Event Processor (CEP), which uses the Siddhi query language. Users are therefore able to create their own custom throttling policies by writing custom Siddhi queries.

  • The specific combination of attributes being checked in the policy needs to be defined as the key (also called the key template). The key template usually includes a predefined format and a set of predefined parameters. It can contain a combination of allowed keys separated by a colon (:), where each key must start with the prefix $. The following keys can be used to create custom throttling policies: 

    resourceKey, userId, apiContext, apiVersion, appTenant, apiTenant, appId, clientIp

This document explains how to deploy a custom throttling policy for the Consumer Data Standards API

  1. Open the <WSO2_OB_APIM_HOME>/repository/deployment/server/synapse-configs/default/api/<USERNAME>--ConsumerDataStandards_vv1.xml file.
  2. Add the  CDS Throttling Policy Handler immediately before the Throttle Handler. These 2 handlers must be in the following order: 

    <handler class="com.wso2.finance.open.banking.custom.throttling.CDSThrottlingPolicyHandler"/>
    <handler class="org.wso2.carbon.apimgt.gateway.handlers.throttling.ThrottleHandler"/>
  3. Use admin credentials and sign in to the Admin portal at https://<WSO2_OB_APIM_HOST>:9443/admin.
  4. Expand THROTTLING POLICIES and select the CUSTOM POLICIES tab.
  5. To add a new policy, click DEFINE POLICY.
  6. Fill in the required details and click APPLY RULE

    As shown in the above Siddhi query, the throttle key must match the key template format. If there is a mismatch between the key template format and the throttle key, requests will not be throttled.

For the Unattended traffic, 20 sessions per day, per customer, per data recipient throttling policy:

This is available only as a WSO2 Update and is effective from September 14, 2021 (09-14-2021). For more information on updating WSO2 Open Banking, see Updating WSO2 Products.

  • The throttling policy is available in <WSO2_OB_APIM_HOME>/repository/resources/finance/throttling-policies/au/Unattended-SessionsPerDayPerCustomerPerDR.
  • The throttle key: 

    $appId:$userId:$customProperty.customerStatus
  •  The updated Siddhi app is available in <WSO2_OB_BI_HOME>/resources/finance/cds-siddhi-files/APIRawDataSubmissionApp.siddhi.

Do the following configurations:

  1. To enable Unattended session count throttling:
    1. Open the <WSO2_OB_APIM_HOME>/repository/conf/deplpoyment.toml file
    2. To enable Unattended session count throttling, add the following configurations:

      [open_banking.au.unattended_session_count_throttling]
      enable = true
    3. Configure the openbank_ob_reporting_statsdb database, using the following tags. Update the values with your database configurations. 

      [open_banking_reporting_database]
      config.url = "jdbc:mysql://localhost:3306/openbank_ob_reporting_statsdb?autoReconnect=true&useSSL=false"
      config.username = "DB_USER"
      config.password = "DB_PASS"
      config.driver = "com.mysql.jdbc.Driver"
      
      [open_banking_reporting_database.config.pool_options]
      maxActive = "150"
      maxWait = "60000"
      minIdle ="5"
      testOnBorrow = true
      validationQuery="SELECT 1"
      #Use below for oracle
      #validationQuery="SELECT 1 FROM DUAL"
      validationInterval="30000"
      defaultAutoCommit=false
      
  2. To enable token encryption, add the following configurations to the deployment.toml files and restart the servers.

    • <WSO2_OB_APIM_HOME>/repository/conf/deplpoyment.toml file
    • <WSO2_OB_IAM_HOME>/repository/conf/deplpoyment.toml file

      [open_banking.bi_server.data_publishing.token_encryption]
      enable=true
      secretKey="wso2"