I am using a quota policy as below, 10 request per week,
<Quota name="Quota-1" type="flexi"> <DisplayName>Quota-1</DisplayName> <Properties/> <Distributed>true</Distributed> <Synchronous>true</Synchronous> <Identifier ref="request.queryparam.apikey"/> <Allow countRef="verifyapikey.Verify-API-Key-1.apiproduct.developer.quota.limit"/> <Interval ref="verifyapikey.Verify-API-Key-1.apiproduct.developer.quota.interval"/> <TimeUnit ref="verifyapikey.Verify-API-Key-1.apiproduct.developer.quota.timeunit"/> </Quota>
Now I have reached the limit. So I want to use Reset quota,
<ResetQuota name="Reset-Quota-1"> <DisplayName>Reset Quota-1</DisplayName> <Properties/> <Quota name="Quota-1"> <Identifier ref="request.queryparam.apikey"> <Allow>10</Allow> </Identifier> </Quota> </ResetQuota>
So this should ideally allow 10 more requests based on identifier right?
But in trace it shows this,
My requirement is when quota(10 request per week) is completed I want to reset it again to 10 requests per week.
How can I do this?
Solved! Go to Solution.
@Barahalikar Siddharth , Great Question.
Ideally, I think, You should place reset quota policy in fault rules with a specific condition match to reset quota.
The ResetQuota policy should really be called "IncreaseQuota" or "TempIncreaseQuota" because the way it works is:
- Add a value to available.count
- Subtract that same value from used.count
Those changes disappear when the Quota policy next resets!
@Barahalikar Siddharth , See similar question here that explains how it works
@Anil Sagar, ok so reset quota adds 'n' more requests to my quota limit.
But after reset I can hit the service for more than 'n' times and no error( limit exceeded ) is thrown.
Where should the reset quota be placed? after quota?
@Barahalikar Siddharth , Great Question.
Ideally, I think, You should place reset quota policy in fault rules with a specific condition match to reset quota.
The ResetQuota policy should really be called "IncreaseQuota" or "TempIncreaseQuota" because the way it works is:
- Add a value to available.count
- Subtract that same value from used.count
Those changes disappear when the Quota policy next resets!
Than you @Anil Sagar, your idea about fault rule worked.
My configuration was,
<FaultRules> <FaultRule name="quota-violation"> <Step> <Name>Extracting-Fault-String</Name> </Step> <Step> <Name>fault_Quota-Limit</Name><!-- custom error by assign message --> </Step> <Step> <Name>Reset-Quota-1</Name> </Step> <Condition>(fault.name == "QuotaViolation")</Condition> </FaultRule> </FaultRules>
Type a product name