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
Newsletter
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Google Cloud Pub/Sub vs. AWS SNS and SQS: One Java API for Both With MultiCloudJ
  • Passwordless Image Pulls in Kubernetes With ServiceAccount Tokens and a Credential Provider
  • Zero Trust for Agents: A New Lens to Secure Agents
  • Reusable Operational Playbooks With Agent Skills

Trending

  • How to Format Articles for DZone
  • Function Calling: Responses API vs Chat Completions
  • Bolting an LLM Onto a System That Can't Afford to Be Wrong
  • Using LLMs to Generate Unit Tests and Review Pull Requests in Spring Boot

Draft This article hasn't been published, so readers can't see it.

In moderation This article is waiting for review, so readers can't see it yet.

Deleted This article has been deleted, so readers can't see it.

  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
·
Jul. 02, 18 · Tutorial
Post on X (opens in a new tab) Share on LinkedIn (opens in a new tab)
7.9K Views

Join the DZone community Save articles, join the discussion, and download Refcards and Trend Reports with a free account.

Join for free Already a member? Log in

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

  • Google Cloud Pub/Sub vs. AWS SNS and SQS: One Java API for Both With MultiCloudJ
  • Passwordless Image Pulls in Kubernetes With ServiceAccount Tokens and a Credential Provider
  • Zero Trust for Agents: A New Lens to Secure Agents
  • Reusable Operational Playbooks With Agent Skills

Partner Resources

×

Comments

Loading comments

The comments didn't load

Please try again in a moment.

Likes

Loading

The next likes didn't load. Please try again.

The likes didn't load

Please try again in a moment.

See who liked this

Log in or join DZone for free to see who liked this article.

Log in Join for free
  • 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