DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
  1. DZone
  2. Data Engineering
  3. Databases
  4. WSO2 API Microgateway 2.6.0: Cheat Sheet

WSO2 API Microgateway 2.6.0: Cheat Sheet

What Is WSO2 API MicroGateway (MGW) and the core features? When do use it?

Chanaka Fernando user avatar by
Chanaka Fernando
CORE ·
Nov. 21, 18 · Opinion
Like (3)
Save
Tweet
Share
13.19K Views

Join the DZone community and get the full member experience.

Join For Free

What Is WSO2 API MicroGateway (MGW)?

It is a lightweight proxy for your APIs.

Core Features

  • Security via OAuth2, JWT
  • Throttling
  • Usage metering (Analytics)
  • Low resource usage (2CPU, 256 MB RAM)
  • Fast bootup time

When to Use

  • When there is unusual traffic for an API or a set of APIs, you can spawn an MGW to serve traffic during that period without impacting the performance of other APIs
  • When there is a need to run a gateway in a lockdown environment that does not have connectivity to other API management components (e.g. Publisher, Store, KM)
  • When deploying an API gateway within a microservices architecture where gateway acts as a sidecar to the main service (or API)

How API MGW Works

  • API developers use the Publisher interface to create the APIs
  • API admins publish this API
  • API MGW will connect to the API publisher and generate a micro-gw runtime
How WSO2 API Microgateway works

How to Invoke an API

  • Log into the developer-portal (Store) and subscribe to the API through an application
  • Generate an access token (JWT or OAuth2 token)
  • Send the request along with the token

e.g. curl -k -i -H “Authorization: Bearer <JWT_token | OAuth2_token>” <API_url>

What Are Labels and How Do You Use Them With MGW?

  • Labels allow the users to create an MGW runtime with a set of APIs
WSO2 API Microgateway labels
  • The label needs to be specified in the admin portal (https://<hostname>:9443/admin)
  • When you are creating and publishing an API through the publisher portal, you can see the label you created in the previous step under “Microgateways” category in the Manage->Gateway Environments section of the API creation wizard
  • Once you select the label from that menu, this particular API will get assigned to the selected label
  • Using the micro-gw CLI tool, you can create a microgateway runtime with this label name which will eventually create the microgateway with all the APIs, which has this particular label:

e.g. micro-gw setup <project name> -l <label name>

micro-gw build <project name>

How to Handle Multiple Environments With Different Endpoints

  • Dev, Staging, UAT, Prod environments can have different URLs for backend endpoint
  • Use system variables to override endpoint information
  • Override production endpoint (after building the MGW)

e.g. bash gateway -e TestAPI.v1.prod.endpoint.0=”http://wso2.com"

  • Override sandbox endpoint

e.g. bash gateway -e TestAPI.v1.sand.endpoint.0=”http://wso2.com"

  • Override with load balanced endpoint

e.g. bash gateway -e TestAPI.v1.prod.endpoint.0=”http://wso2.com" -e TestAPI.v1.prod.endpoint.1=”http://support.wso2.com"

  • Override with backend basic authentication details

e.g. bash gateway -e TestAPI.v1.prod.basic.username=”admin” -e TestAPI.v1.basic.password=”admin”

How to Monitor MGW

  • In a locked down environment, the connections to other components can come and go
  • Analytics (monitoring) data needs to be stored locally and published when connected to an analytics runtime
WSO2 API MGW analytics process
  • API requests received at the microgateway and the relevant analytics metadata are written into files
  • A file rotating task which is configured to run periodically will rotate and archive the original file allowing the new file to get created
  • A file upload task which is configured to run periodically will upload the archived files to the microservice which is running in the analytics server.

https://localhost:9444/micro-gateway-analytics/v0.10/usage/upload-file

  • These archived files are stored in the WSO2AM_STATS_DB database in a separate table with the name AM_USAGE_UPLOADED_FILES.
  • A separate task running in the APIM analytics server process these files and publish events to the stream processing components of the analytics server.
  • Stream processing component of the analytics server will process this information and stored in the processed data table which will be used by the API publisher and store components.

References

Working with the API Microgateway — API Manager 2.6.0 — WSO2 Documentation
The following topics explain further details about the API Microgateway, its architecture and capabilities, and how to…docs.wso2.com

API

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • A Beginner's Guide to Back-End Development
  • Top 10 Secure Coding Practices Every Developer Should Know
  • Artificial Intelligence in Drug Discovery
  • Public Cloud-to-Cloud Repatriation Trend

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: