Modify the HTTP status 503 in Concurrent Rate Limit

Not applicable

Hello,

We have a use case where we need to modify the http status code in concurrent rate limit from 503 to 429.

Lets say when the limit is reached in concurrent rate limit then the policy would return 503.

So instead of 503 we would like to return 429.

This is a special use case where in our caller would like to handle it when returned 429 status.

0 2 722
2 REPLIES 2

Hi @Hemanth

In your proxy, in the DefaultFaultRules - Include a RaiseFault policy

RaiseFault policy:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<RaiseFault async="false" continueOnError="false" enabled="true" name="Raise-Fault-1">
    <DisplayName>Raise Fault-1</DisplayName>
    <Properties/>
    <FaultResponse>
        <Set>
            <Headers/>
            <Payload contentType="application/json" variablePrefix="#" variableSuffix="%">
            {
              "errorInfo": {
                "status": "failure",
                "detail": {
                    "code": "429",
                    "text": "Too Many Requests",
                    "severity": "error"
                    }
                }
            } 
        </Payload>
            <StatusCode>429</StatusCode>
            <ReasonPhrase>Too Many Requests</ReasonPhrase>
        </Set>
    </FaultResponse>
    <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
</RaiseFault>

And in the Target End point configuration, under DefaultRules, have the RaiseFault before the ConcurrentRateLimit policy

<DefaultFaultRule name="DefaultFaultRule">
        <AlwaysEnforce>true</AlwaysEnforce>
        <Step>
            <Name>Raise-Fault-1</Name>
            <Condition>(concurrentratelimit.Concurrent-Rate-Limit-1.available.count == 0)</Condition>
        </Step>
        <Step>
            <Name>Concurrent-Rate-Limit-1</Name>
        </Step>
    </DefaultFaultRule>

NOTE: In the condition above, the naming convention for the count is concurrentratelimit.{your_concurrentratelimit_policyName}.available.count

Let me know if it works.

@Hemanth - did it work for you?