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 Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Beyond Manual Annotation: Engineering Self-Correcting Pseudo-Labeling Pipelines
  • Building Threat Intelligence Pipelines Using Python, APIs, and Elasticsearch
  • Implementing Secure API Gateways for Microservices Architecture
  • Contract-First Integration: Building Scalable Systems With Flyway, OpenAPI, and Kafka

Trending

  • Build a GitHub Slack Bot With AWS Bedrock and MCP, Part 1
  • Chaos Engineering Has a Blind Spot. Agentic AI Lives in It.
  • Securing the AI Host: Spring AI MCP Server Communication With API Keys
  • Is the Data Warehouse Dead? 3 Patterns From Enterprise Architecture That Answer This Question
  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.

By 
Anupam Gogoi user avatar
Anupam Gogoi
·
Jul. 02, 18 · Tutorial
Likes (3)
Comment
Save
Tweet
Share
7.7K 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.

Related

  • Beyond Manual Annotation: Engineering Self-Correcting Pseudo-Labeling Pipelines
  • Building Threat Intelligence Pipelines Using Python, APIs, and Elasticsearch
  • Implementing Secure API Gateways for Microservices Architecture
  • Contract-First Integration: Building Scalable Systems With Flyway, OpenAPI, and Kafka

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

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

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook