This documentation is for WSO2 API Manager 2.2.0. View documentation for the latest release.

All docs This doc
Skip to end of metadata
Go to start of metadata

Configuring the API Microgateway locally

Configuring the API Manager

  1. Download WSO2 API Manager.

  2. In the <API-M_HOME>/repository/conf directory of the all-in-one API Manager distribution, open the registry.xml file and add the following task,

    If you are using a distributed setup, change the registry.xml file of the Publisher node.
    <task class="org.wso2.carbon.apimgt.micro.gateway.usage.publisher.tasks.UploadedUsageCleanUpTask" name="UploadedUsageCleanupTask">
    <trigger cron="0 0 0/1 1/1 * ? *"/>
    <property key="fileRetentionDays" value="1"/>
  3. In the <API-M_HOME>/repository/conf directory, open the file and enable usage data publishing, as shown below:

Configuring the Microgateway

  1. Download the WSO2 API Manager Microgateway.

  2. Open the <MICRO-GW_HOME>/repository/conf/carbon.xml file and offset the Microgateway node by 1, as shown below:

    <!-- Ports offset. This entry will set the value of the ports defined below to the define value + Offset.
    e.g. Offset=2 and HTTPS port=9443 will set the effective HTTPS port to 9445 →
  3. In the <MICRO-GW_HOME>/repository/conf/api-manager.xml file, point the Microgateway’s Key Manager to the default API Manager's Key Manager by modifying the <APIKeyValidator> section.

    <!-- Server URL of the API key manager -->     
    <!-- Admin username for API key manager. -->
    <!-- Admin password for API key manager. -->
  4. To sync the APIs and throttling policies, and upload the usage stats, modify the file in the <MICRO-GW_HOME>/repository/conf directory by adding the respective URLs.

    If you make any changes to the APIs or throttling policies after starting the server, restart the server to make sure the changes are synced.

    # Configure the API gateway url below:
    # Configure the publisher url below:
    # Configure the publisher url below:
    # Configure the keymanager url below:
    # Configure the publisher url below:
    # Configure the publisher url below:
  5. Add the following tasks in the <MICRO-GW_HOME>/repository/conf/registry.xml file,

    <task class="org.wso2.carbon.apimgt.micro.gateway.usage.publisher.tasks.APIUsageFileUploadTask" name="APIUsageFileUploadTask">
    <trigger cron="0 0 0/1 1/1 * ? *"/>
    <task class="org.wso2.carbon.apimgt.micro.gateway.usage.publisher.tasks.APIUsageFileCleanupTask" name="APIUsageFileCleanupTask">
    <trigger cron="0 0 1 1/1 * ? *"/>
    <property key="fileRetentionDays" value="35"/>
  6.  In the <MICRO-GW_HOME>/repository/conf/api-manager.xml file, enable analytics, change the Publisher class, and skip event receiver connection, as shown below:

    <!-- Enable Analytics for API Manager →
    <!-- API Usage Data Publisher. -->  
    <!-- Below property is used to skip trying to connect to event receiver nodes when publishing events even if
                the stats enabled flag is set to true. -->
  7. Add the following entries to the file in the <MICRO-GW_HOME>/repository/conf directory.
  8. Modify the file in the <MICRO-GW_HOME>/repository/conf directory using the Microgateway port.

    connectionfactory.TopicConnectionFactory = amqp://admin:[email protected]/carbon?brokerlist='tcp://localhost:5673'
    connectionfactory.QueueConnectionFactory = amqp://admin:[email protected]/test?brokerlist='tcp://localhost:5673'

Test the Microgateway locally

  1. Start the API Manager server.
  2. Publish and invoke a few APIs.
  3. Start the Microgateway server.
  4. Invoke the deployed APIs.

    Change the access token accordingly.
    curl -X GET "" -H "accept: application/json" -H "Authorization: Bearer 302a4a81-5318-3ad8-82f3-82f393c0ad0e" -k
  5. If the default distribution has Analytics enabled, you see statistics in the API Manager Publisher and Store.

Configuring the Microgateway in the Cloud

Follow the steps in the Working with Hybrid API Management page with the following modifications for each step.

Step 1 - Instead of the On-Prem Gateway, use the Microgateway zip file.

Step 2 - Run the or cloud-init.bat scripts in the <MICRO-GW_HOME>/bin directory.

  • No labels