WSO2 APIM | Sequence to print throttlling messages
Hi everyone, I will be sharing my another experience with the WSO2 API Manager sample use case for API throttling.
Changes done
WSO2 Sequence to print throttling messages in wso2carbon.log file
- Navigate to <APIM_HOME>/repository/deployment/server/synapse-configs/default/sequences directory.
- Open the file named _throttle_out_handler_.xml.
- Update the contents of file _throttle_out_handler_.xml as per the below custom changes
<sequence name="_throttle_out_handler_" xmlns="http://ws.apache.org/ns/synapse">
<property name="X-JWT-Assertion" scope="transport" action="remove"/>
<class name="org.wso2.carbon.apimgt.gateway.handlers.analytics.APIMgtThrottleUsageHandler"/>
<sequence key="_cors_request_handler_"/>
</sequence>
<!-- Custom sequence added starts -->
<sequence name="_throttle_out_handler_" xmlns="http://ws.apache.org/ns/synapse">
<property name="X-JWT-Assertion" scope="transport" action="remove"/>
<class name="org.wso2.carbon.apimgt.usage.publisher.APIMgtThrottleUsageHandler"/>
<sequence key="_cors_request_handler_"/>
<log level="custom">
<property name="API_NAME:VERSION" expression="get-property('api.ut.api_version')"/>
<property name="USER_NAME" expression="get-property('api.ut.userName')"/>
<property name="APPLICATION_NAME" expression="get-property('api.ut.application.name')"/>
<property name="THROTTLED_OUT_REASON" expression="get-property('THROTTLED_OUT_REASON')"/>
<property name="NEXT_ACCESS_UTC_TIME" expression="get-property('NEXT_ACCESS_UTC_TIME')"/>
</log>
<!-- Custom sequence added ends -->
</sequence>
[2022-02-28 12:10:13,409] INFO - LogMediator API_NAME:VERSION = PizzaShackAPI:v1.0.0, USER_NAME = admin@carbon.super, APPLICATION_NAME = DefaultApplication, THROTTLED_OUT_REASON = APPLICATION_LIMIT_EXCEEDED, NEXT_ACCESS_UTC_TIME = 2022-Feb-11 12:15:00+0000 UTC
This log message indicates that the Application Quota has been exhausted i.e. let's say we have provided the quota for Default Application as 10 Req/Min; so if the API subscribed to this application has been called more than 10 times within a minute, the request is throttled out and the API consumer will get HTTP 429 error (too many requests).
This comment has been removed by a blog administrator.
ReplyDelete