Publishing To Anypoint Exchange And Deploying To CloudHub 2.0 Using Maven

Author Name: Sayli Shrungare

This blog is a guide on how you can publish your application to exchange and also deploy the same application to CloudHub 2.0 using Maven.

CloudHub 2.0 

APIs and integrations can be deployed as small, lightweight containers in the cloud using CloudHub 2.0, a fully managed, containerized Integration Platform As a Service (iPaaS).

Why CloudHub 2.0?
  • Enables deployment throughout 12 regions worldwide.
  • Infrastructure and built-in services are scaled up or down dynamically to handle elastic transaction volumes.
  • Integrated security rules that include firewall restrictions, restricted shell access, and encrypted secrets that we don’t need to specify in artifact.json, to safeguard your services and sensitive data. 
  • Encrypts important configuration data in transit and at rest within the Anypoint Platform, including certificates, passwords, and other data.
  • By running each Mule instance and service as a different container, it offers a uniform isolation boundary.
  1. The Mule Maven plugin required to deploy to CloudHub 2.0 should be greater than 3.7.X in your pom.xml.
  2. The application should be published to exchange first.

As CloudHub 2.0 is tightly coupled with the exchange. Before deploying, CloudHub 2.0 will look for the same asset in exchange if the asset is not present deployment will fail. Furthermore, after every change in code, the app version in POM should be updated and then deployed. The packaging type is referred from pom.xml which is:

Steps to publish to exchange using Maven:
  1. Add groupId as your organization ID in your pom.xml. You can get the organization Id by Logging into Anypoint Platform and navigating to Access Management. Look for the name of the top-level organization or the required business group, and view your organization ID in the organization information screen.
  2. To publish to exchange, we need to add the tag distributionManagement and specify the repository, the same repository ID should be specified in settings.xml
	       <name>Exchange2 Repository</name>
  1. In the repository section <repositories> </repositories> in the pom.xml add a new repository tag with the same ID as above.

	<name>Exchange2 Repository</name>

  1. Update the settings.xml file in the .m2 directory with the correct username and password.
    1. ‘Settings.xml‘ file is a configuration file used by Maven to customize the behavior and settings. It is located in the ‘.m2’ directory. We need to specify the authentication credentials for accessing remote repositories that require authentication. Using the settings file, we will be able to deploy our assets to the Anypoint platform.
    2. Connected app: it is an application that has been registered and authorized to access resources and APIs within the Anypoint platform. With the help of OAuth 2.0 and OpenID Connect APIs, the Connected Apps feature offers a framework that enables an external application to interface with the Anypoint Platform. Connected Apps help user delegate their access without sharing sensitive credentials or giving full control of their applications to third parties. Actions taken by connected apps are audited, and users can revoke access at any time. The Connected Apps feature enables you to use secure authentication protocols and control an app’s access to user data. All things considered, employing Connected App credentials rather than account credentials in the Anypoint Platform offers a more secure and controlled way to authenticate and authorization for external applications or custom integrations, ensuring better security and compliance with organizational regulations.

Example of settings.xml file using the connected app:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
					<name>Anypoint Platform Exchange Repository</name>
					<name>mulesoft release repository</name>

Replace the ${clientId} and ${clientSecret} with correct values from your connected app and replace the groupId as well.

  1. Publish the asset to Exchange using this Maven command:

mvn deploy

Below is the command used to publish to exchange -s command is used to specify the settings file location:

After deploying you will get build success:

  1. To view the asset in exchange, add type=app.

After all these prerequisites are successfully completed we can deploy the app to CloudHub 2.0 below are the steps:

  1. Add the CloudHub 2.0 configuration in the pom.xml
  • provider: Set to MC, for CloudHub 2.0.
  • server: this should be the same as set in settings.xml. This is not the Mule server name.
  • target: Specify either a shared space or a private space available in your Deployment Target values in CloudHub 2.0. 
  • secureProperties: this is used to encrypt values, so we don’t need to specify in artifact.json.
  •  Properties: if you are using HTTPS in CloudHub 2.0 the port for HTTPS is also 8081, and you need to enable the lastMileSecurity property in deploymentSettings. This will enable HTTPS traffic.
  1. To deploy your application to CloudHub 2.0 use the command:

MVN clean deploy -DmuleDeploy

Below is the command used  -s command is used to specify the settings file location.

After successfully deploying.

  1. After a successful deployment of the app, the status of the application will be Running in Runtime Manager.

This should be the last step toward your deployment. You should be able to access your application via Postman or any other REST client.

We use cookies on this site to enhance your user experience. For a complete overview of how we use cookies, please see our privacy policy.