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. Using API instance in Anypoint Platform 2

Using API instance in Anypoint Platform 2

In this article, I am going to explain the main purpose of API instance and its use in the Anypoint Platform.

Anupam Gogoi user avatar by
Anupam Gogoi
·
Jul. 02, 18 · Tutorial
Like (3)
Save
Tweet
Share
6.25K Views

Join the DZone community and get the full member experience.

Join For Free

Introduction

In this article, I am going to explain the main purpose of API instance and its use in the Anypoint Platform. This is a follow-up article of the previous one. 

What is API Instance?

Imagine the Java class paradigm. Multiple objects can be created from a single Java class. Approximately the same principle applies to this API instance concept. Let's suppose that our API (The RAML specs that we created in Design Center and published in the Exchange as an asset) is the Java class. Now we can create multiple instances from the API in multiple environments.  Just imagine something as shown below to get an idea.

Image title


What's the Use of it?

You can create various instances of the same API and apply different policies to them separately. Please check the documentation.

How to Use it?

It's kind of hit and miss to find out how to make proper use of it as the official documentation of Mule has not provided yet a proper roadmap of API development. So, here are the basic steps you need to do. (Please read my previous article for more detail).

Step 1

Create an instance of the API.

Image title

Here, I'm creating an API instance named demo-instance

Step 2

Once the API instance is created, you will get an API instance ID. Implement the API in Anypoint Studio. In the implementation, you configure API Autodiscovery and provide the API instance ID. By doing so, you are telling the Anypoint Platform to automatically wire that instance of the API to the implementation.

Step 3

Once the application is deployed, copy the URL of the application. Now go the Exchange and look for the API asset. Navigate to API instances option of the API and configure the instance demo-instance with the implementation URL. Here is a snapshot:

Image title

Step 4

Once the API instances are defined, you can choose them to be executed for the API. Here is a screenshot:

Image title

In the figure above, we are executing the GET operation of the resource against the API instance chosen (demo-instance). All statistics for this operation will be registered in that particular instance. 

Conclusion

It's easy to make use of the API instance in the Anypoint Platform. 

A Small Experiment:

I performed a small experiment by creating two API instances (Basic Endpoint) for the same API and configuring two API Autodiscovery elements (providing the API instance IDs in the implementation. Here is the screenshot:

Image title

On deploying the application to Cloudhub, the instances were successfully auto-discovered.

Issue 1

I have configured the instances in Exchange for the API and made calls to an API operation for both of the instances. But unfortunately, only one of the instances registered the statistics.

Issue 2

Applied Client Id enforcement policy on instance-one. Unfortunately, the policy is applied to instance-two also automatically.

Remark

I will try to resolve this issue and write another article on it.

Thanks.

API

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Easy Smart Contract Debugging With Truffle’s Console.log
  • Handling Automatic ID Generation in PostgreSQL With Node.js and Sequelize
  • The Enterprise, the Database, the Problem, and the Solution
  • How to Configure AWS Glue Job Using Python-Based AWS CDK

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: