Motivation;
We need to have TPS limit across the whole tenant based on their
subscription level, that we can change, but tenant admins cannot.So that we
can inform the customers that the subscription plan needs to be upgraded.

Design:

1. Write a custom handler by extending
org.apache.synapse.rest.AbstractHandler

2. Configure subscription plans(tiers) in a xml file and store it the file
system . <SERVER_HOME>/repository/conf/throttling/tenant_tiers.xml

3. Make the custom handler an osgi bundle and within the bundle activation,
initialize the throttling policy based on the said configurations file.

4. As api call hits the handler, get the subscription plan from database
and cache it in memory so that next time it will pick from the cache.

5.Pass the subscription plan to throttle engine get the results as a
boolean.

6.Write a background task that updates and clean up the cache in regular
intervals (1 hour).

7.Add the handler configuration to velocity_template.xml


Thanks & Regards,
Ishara Cooray
Senior Software Engineer
Mobile : +9477 262 9512
WSO2, Inc. | http://wso2.com/
Lean . Enterprise . Middleware
_______________________________________________
Architecture mailing list
[email protected]
https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture

Reply via email to