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

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

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

SBOMs are essential to circumventing software supply chain attacks, and they provide visibility into various software components.

Related

  • Generic and Dynamic API: MuleSoft
  • Releasing MuleSoft API
  • API-Led Example: MuleSoft
  • On-Demand-Schedulers With MuleSoft CloudHub APIs

Trending

  • How We Broke the Monolith (and Kept Our Sanity): Lessons From Moving to Microservices
  • How to Troubleshoot Common Linux VPS Issues: CPU, Memory, Disk Usage
  • Leveraging AI: A Path to Senior Engineering Positions
  • Seata the Deal: No More Distributed Transaction Nightmares Across (Spring Boot) Microservices
  1. DZone
  2. Software Design and Architecture
  3. Integration
  4. Create Clusters in MuleSoft Runtime Manager Using APIs

Create Clusters in MuleSoft Runtime Manager Using APIs

Learn how to create clusters of a group of servers in MuleSoft, using either the Anypoint Platform console, or the RunTime Manager API.

By 
Shantha Priya user avatar
Shantha Priya
·
Oct. 10, 17 · Tutorial
Likes (6)
Comment
Save
Tweet
Share
5.7K Views

Join the DZone community and get the full member experience.

Join For Free

In the case of MuleSoft, we can create clusters of a group of servers either using the Anypoint Platform console, or by using the RunTime Manager API. The following list of APIs should be used sequentially in order to create a cluster in Runtime through the API.

We mainly go for the cluster concept in MuleSoft to ensure high availability of the Mule applications running on the server, which means that all the servers that belong to a cluster will have one single application running on the top of it.

Note: Mulesoft API's are by default REST API  so all the output will be in JSON Format.

Step 1: Get the Authorization Token

The first step is to authenticate our AnyPoint Platform account in order to get access to it. The following API is used to get the authorization token by passing our Anypoint Platform login credentials.

API: https://anypoint.mulesoft.com/accounts/login

Method: POST

Parameters: username=

                           password=

Output:Image title

From the above output, we can make use of the access token as our authentication-id to perform the further actions.

Note:This token will be valid only a shorter duration after which you have to generate a new token.

Step 2: Get the Organization ID

After generating the access token, pass that access token value as a header in order the get the organization ID.

As in Anypoint Platform, all the APIs, Clusters, Mule applications, and servers fall under the organization. We can have multiple organization and sub-organizations under one Anypoint Platform account. 

API: https://anypoint.mulesoft.com/accounts/api/me

Method: GET

Headers:

Authorization= ‘access_token’

OUTPUT:

Image title

From the above output in JSON format, obtain the id of the organization class, as this will be passed as a parameter in the upcoming API.

STE 3: Get the Environment ID

After obtaining the organization id, we have to filter the environment under which the cluster should be created. Under each organization, we can create multiple environments; the default one would be the sandbox environment. 

API: https://anypoint.mulesoft.com/accounts/api/organizations/{org-id}/environments

Method: GET

Headers: Authorization= bearer ‘access_token’

OUTPUT:

Image title


Step 4: Get the List of Servers

After getting the desired environment id and organization id, we have to be aware of the list of the servers available in the environment, and we have to fetch the id assigned to the particular server that has to be added to the cluster. In order to obtain that, we make use of the below API.

API: https://anypoint.mulesoft.com/hybrid/api/v1/servers    

Method: GET

Headers: Authorization= bearer ‘access_token’

                 X-ANYPNT-ORG-ID= ‘org-id’

                 X-ANYPNT-ENV-ID=  ‘env-id’

Here we pass the headers of token org-id and env-id that are obtained from the previous API's.

OUTPUT:

Image title

From the output, we obtain the server id of the servers that are present in that particular environment that should be formed as a cluster.

Step 5: Create Clusters

After obtaining all the details, we can go ahead and pass the same set of headers that we have sent for the previous API along, which you should pass as a message body in JSON format that provides the name of a cluster that we are going to create along with the server id's field (mandatory).

Apart from this, we can also pass the Server IP and a few other fields as a field in the JSON body.

API: https://anypoint.mulesoft.com/hybrid/api/v1/clusters     

Method: POST

Headers: Authorization= bearer ‘access_token’

                 X-ANYPNT-ORG-ID= ‘org-id’

                 X-ANYPNT-ENV-ID=  ‘env-id’

Body:

{  "name": "cluster1",

   "multicastEnabled": "true",

   "servers": [ {"serverId" : 30433433}]

}

Finally, the cluster will be created with either a single or a group of servers; provided that the servers are of multi-cast, then the servers should be up and running, whereas in uni-cast, the server can even be in disconnected mode.

cluster MuleSoft API

Opinions expressed by DZone contributors are their own.

Related

  • Generic and Dynamic API: MuleSoft
  • Releasing MuleSoft API
  • API-Led Example: MuleSoft
  • On-Demand-Schedulers With MuleSoft CloudHub APIs

Partner Resources

×

Comments

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

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

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 100
  • Nashville, TN 37211
  • [email protected]

Let's be friends: