Hi All, With the new throttling implementation using CEP as the global throttling engine users will be able to create their own custom throttling policies by writing custom siddhi queries. This feature will be available only to super tenant users in 2.0.0 relesae. Custom policies will be applied globally across all APIs. To create a custom policy users need to create their own key template which will be used as the Throttling Key.
A key template can contain a combination of allowed keys separated by a colon ":" and each key should start with "*$"* prefix. In APIM 2.0.0 users can use the following keys to create custom throttling policies. *appKey,apiKey,subscriptionKey,resourceKey,userId,apiContext,apiVersion,appTenant,apiTenant,appId* *Sample Custom Policy* The following sample custom policy will allow the admin user to send 5 request per minute to the pizzashack API. *Key template * $userId:$apiKey *Siddhi Query* FROM RequestStream SELECT userId, ( userId == '[email protected]' and apiKey == '/pizzashack/1.0.0:1.0.0') AS isEligible , str:concat('[email protected]',':','/pizzashack/1.0.0:1.0.0') as throttleKey INSERT INTO EligibilityStream; FROM EligibilityStream[isEligible==true]#window.time(1 min) SELECT throttleKey, (count(throttleKey) >= 5) as isThrottled group by throttleKey INSERT ALL EVENTS into ResultStream; As shown in the above Siddhi query, *throttle key should match keytemplate* format. If there is a mismatch between the Keytemplate format and throttlekey requests will not be throttled. Please share your thoughts and suggestions on this. Thanks, Sam -- *Sam Sivayogam* Software Engineer Mobile : +94 772 906 439 Office : +94 112 145 345 *WSO2, Inc. :** wso2.com <http://wso2.com/>* lean.enterprise.middleware.
_______________________________________________ Architecture mailing list [email protected] https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture
