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?
1 Like
@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.
- If you place the reset quota after quota policy in request / response flow,
- It will never execute / keep increasing quota of the request so that quota will never end.
- It will never execute because flow will be changed to error flow & reset quota will never execute
- It will keep increasing quota & quota will never end because reset quota actually works as increase quota / tempIncreaseQuota. For more detail see link here.
- If you place the reset quota before quota policy in request / response flow,
- It will keep increasing quota of the request so that quota will never end until unless you conditionally execute reset quota to increase quota
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:
Those changes disappear when the Quota policy next resets!
2 Likes
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>