APIAuthenticationHandler:Validates the OAuth2 bearer token used to invoke the API. It also determines whether the token is of type
MessageContextvariables as appropriate.
APIThrottleHandler:Throttles requests based on the throttling policy specified by the
policyKeyproperty. Throttling is applied both at the application level as well as subscription level.
APIMgtUsageHandler:Publishes events to WSO2 Data Analytics Server (WSO2 DAS) for collection and analysis of statistics. This handler only comes to effect if . See Working with Statistics for more information.
APIMgtGoogleAnalyticsTrackingHandler:Publishes events to Google Analytics. This handler only comes into effect if Google analytics tracking is enabled. See for more information.
APIManagerExtensionHandler: Triggers extension sequences. By default, the extension handler is listed at last in the handler chain, and therefore is executed last. You cannot change the order in which the handlers are executed, except the extension handler. To configure the API Gateway to execute extension handler first, uncomment the
<ExtensionHandlerPosition>section in the
<APIM_HOME>/repository/conf/api-manager.xmlfile and provide the value
top. This is useful when you want to execute your own extensions before our default handlers in situations like doing additional security checks such as signature verification on access tokens before executing the default security handler.
See Adding Mediation Extensions.
Prior to API Manager 1.9.1 version, this message logging is handled by
APIManagerExtensionHandler. Addition to the above mentioned Handlers, from API Manager version 1.9.1 onwards
APILogMessageHandler has introduced.
APILogMessageHandler is a sample handler comes with WSO2 API Manager that can be used for logging.
Why logs have removed from
The primary purpose of ExtensionHandler is handling extensions to mediation and not for logging messages. When the logs also included in ExtensionHandler, there's a limitation to improve the ExtensionHandler for developing features because it breaks the logs.
For example, When the ExtensionHandler moves to the top of the handlers set, most of the logs print null values since the handler runs before the APIAuthenticationHandler. Due to this fact,it was decided to remove the logs from extension handler and APILogMessageHandler introduced as a sample.
Inorder to enable logging by invoking APILogMessageHandler, follow below steps.
To enable Message Logging per API :
Open the synapse Configuration of the API located in
<APIM_HOME>/repository/deployment/server/synapse-configs/default/apidirectory and add below handler before </Handlers>.
Copy the following code into the <APIM_HOME>/repository/conf/log4j.properties file to enable printing DEBUG logs.
log4j.logger.org.wso2.carbon.apimgt.gateway.handlers.logging.APILogMessageHandler = DEBUG
Restart API Manager server.
To enable Message Logging into APIS created from publisher automatically :
Open velocity_template.xml file located in <APIM_HOME>/repository/resources/api_templates directory and copy the following handler beofore </handlers>.
Restart API Manager server.
Writing a custom handler
The outcome of using a Class Mediator vs. a Synapse Handler are very similar. However, when using a custom handler you need to maintain a customized velocity template file that needs to be manually merged when you upgrade your product to a newer version. Therefore, it is recommended to use custom Handlers when you wish to specify the exact order of execution of JARs as this can not be done with Mediators.