MuleSoft Technical Guides

Guides for MuleSoft Developers.

Deploy Applications to Runtime Manager using Anypoint CLI

Deploy Applications to Runtime Manager using Anypoint CLI

MuleSoft Anypoint Platform provides a command-line tool to work with the Anypoint platform and Anypoint Platform Private Cloud Edition. We can deploy applications to Runtime Manager using Anypoint CLI tool.

 

Setting up Anypoint CLI

  1. Download and install NodeJS, if not installed already
  2. Once installed, run the following command to install Anypoint CLI, npm install -g anypoint-cli@latest

Deploying Application

First, log in to the Anypoint Platform Account from CLI using the following command, anypoint-cli –username=”user”

CLI login

If a production environment is available, CLI will connect to that; otherwise, it will connect to the Design environment. To switch the environment, use the below command

use environment Sandbox

cli-switch-env.

Run the following command to deploy the Application to CloudHub.

runtime-mgr cloudhub-application deploy “app-name” “JAR or ZIP location”

cli-arm-deploy-app

Options available for deployment command

The deployment command lets us manage all the aspects of deployment via CloudHub. Following are the options provided-

  1. –runtime: Option to specify the Mule Runtime. Default is the latest one.
  2. –workers: Number of workers. 1 by default.
  3. –workerSize: Worker Size in vCores. 1 by default.
  4. –region: Region where Application will be deployed. us-east-2 is default.
  5. –property: Specify a property in key-value pair. E.g. –property “password=1234” or –property “password:1234”. To pass more than one, specify –property option for each one. The document specifies that only “:” can be used for key-value pairs but “=” also works.
  6. –propertiesFile: If provided, values from the file will overwrite all the properties, even those which are not in the file. Syntax: –propertiesFile “D:\file\prop.txt”
  7. –persistentQueues: Enable or disable persistent Queues. Value can be True or False. False by default.
  8. –persistentQueuesEncrypted: Enable or disable persistent queue encryption. Value can be True or False. False by default
  9. –staticIPsEnabled: Enable or disable static IPs. Value can be True or False. False by default
  10. –objectStoreV1: Enable or disable object store v1. Value can be True or False. False by default
  11. –autoRestart: Automatically restart app when not responding. Value can be True or
  12. –o/–output: Specifies the output format for deployment summary. Supported values are table, text and JSON. For interactive mode ‘table’ is default whereas for non-interactive, text is default.
  13. –f/–fields: Specifies the fields in the output. Multiple fields can be provided using comma separated values to limit the output. E.g -f “File Name,Region”
  14. –help: Outputs usage information

cli-rm-deploy-help

Managing the deployed Application

Below are a few CLI commands to manage deployed applications.

#To Stop Application

runtime-mgr cloudhub-application stop “app-name”

#To Start Application

runtime-mgr cloudhub-application start “app-name”

#To restart Application

runtime-mgr cloudhub-application restart “app-name”

#To Delete Application

runtime-mgr cloudhub-application delete “app-name”

#To Modify the existing Application. This command takes all the options as a deploy command.

runtime-mgr cloudhub-application modify “app-name” [options]

 

By following these steps developers can Deploy Applications to Runtime Manager using Anypoint CLI.

Find more MuleSoft Anypoint solutions at Caelius Consulting Resource Center. 

 

Create Custom Connector using Mule XML SDK

MuleSoft Custom Connector

MuleSoft creates a great opportunity of reusing the readily available connectors but in some cases, the connector might not be available for connecting to a particular system. We need to write custom logic like spring beans/Java code to connect to it. However, if we don’t want to include the same logic in every API integration which implements the requirement, we can create a custom connector. There are broadly two types of custom connectors:

  1. Java SDK
  2. XML SDK.

This article will look at the XML SDK , which provides an easier learning curve than Java SDK and is more like developing a Mule application.

Anatomy of XML SDK

  1. Operations – An operation in XML SDK is relatable to a Java method with a set number of arguments required (can have zero arguments as well), a body to process, and an output.
  2. Properties – To define a global configuration, we can use properties inside a connector. When specified, a user can create a global configuration with defined properties.

Creating a custom connector

The first step while creating a custom connector is to generate a skeleton project.

Run the below command in the command prompt.

mvn archetype:generate -DarchetypeGroupId=org.mule.extensions -

DarchetypeArtifactId=mule-extensions-xml-archetype -

DarchetypeVersion=1.2.0 -DgroupId=demo-connector -DartifactId=demo-

connector -DmuleConnectorName=demo-connector

 

Argument Description
-DarchetypeGroupId Group ID of Archetype in the Mule repository
-DarchetypeArtifactId Artifact ID of the Archetype in the Mule repository
-DarchetypeVersion Version of the aerchetype
-DgroupId Group ID of the user’s Mule application
-DartifactId Artifact Id for user’s application/module
-DmuleConnectorName Name of the connector

Once generated, import it in MuleSoft Anypoint Studio. The structure looks like below:

 xml-sdk-structure

module-Hello.xml contains the main logic implemented by the connector.

Here, we will write a simple connector with two operations. One to modify the incoming query parameter and second to return the sum of two numbers which will further pass in the parameters.

Operation to get sum of two numbers

<operation name="Get-Sum" doc:description="Return the sum of two incoming paramters">
		<parameters>
			<parameter name="num1" type="number" use="REQUIRED"/>
			<parameter name="num2" type="number" use="REQUIRED"/>
		</parameters>
		<body>
			<mule:set-payload
				value="#[vars.num1 + vars.num2]" />
		</body>
		<output type="number" />
	</operation>

Operation to modify the query param

<operation name="Modify-query-parameter"
		doc:description="Modifies the incoming query paramter">
		<parameters>
			<parameter name="qParam" type="string" use="REQUIRED"/>
		</parameters>
		<body>
			<mule:set-payload value="#['Hello ' ++ vars.qParam]" />
		</body>
		<output type="string" />
	</operation>

 

To install the connector locally, run mvn clean install

To use the connector in project, add the dependency

<dependency>
	<groupId>{group id of connector}</groupId>
	<artifactId>{artifact id of connector}</artifactId>
	<version>{version of connector}</version>
	<classifier>mule-plugin</classifier>
</dependency>

Once done, the connector will be available in the Mule palette.

xml-sdk-pallette-view.

Add the operations in the flow as required. Below is the property view for each operation.

xml-sdk-operation-1xml-sdk-operation-2

Conclusion

Mule XML-based SDK is a straightforward and efficient way to create a custom connector and fulfill any ad hoc requirements.

Find more MuleSoft Technical guides at Caelius Consulting MuleSoft Resource Centre.

 

Isolate your CloudHub worker instances using VPN

Isolate your CloudHub worker instances using VPN

MuleSoft CloudHub – A multi-tenant integration platform as a service. Applications hosted on CloudHub workers or instances are balanced by a shared load balancer provided by MuleSoft. At every given point of time, your MuleSoft API deployed on CloudHub might want to interact with the on-premise resources, and for that, we need to have a secured connection tunnel that is not exposed on the public cloud. The article will help you isolate CloudHub worker using VPN.

Anypoint VPC (Virtual Private Cloud)

Anypoint VPC (Virtual Private Cloud) allows you to create a private coherent and secluded network to host your mule applications. VPC allows to connect CloudHub workers to your corporate data center using the below techniques:

· IPSec Tunneling (Secure VPN Tunnel)

· AWS Peering

· AWS Direct Connect

VPC Structure
Source: www.mulesoft.com

 

Lets take a look at the advantages, characteristics, and configurations of Anypoint VPCs.

 

Advantages of MuleSoft Anypoint VPC

· Connect CloudHub to any private cloud or on-premise data center.

· Create a mesh of secure virtual networks within CloudHub.

· Secure your worker instances.

Points to remember while configuring Anypoint VPC

· Ensure you create the VPC in the same region or near your data center or AWS region (VPC Peering).

· Generally the setup has one isolated network for your production environment and another for non-production environments like dev, test, UAT.

· Multiple deployment environments can be mapped to the same VPCs.

· Always create the VPC in the parent business group and share amongst sub-business groups.

Creating a VPC- Virtual Private Cloud 

Creating a VPC is not a hard and fast process and can be done in a couple of minutes.

You need to provide the values of four parameters viz.

· Region

· CIDR block

· Environments

· Business groups

Configure_VPC

VPC Region

VPC region is selected from a cluster of available regions. However, MuleSoft’s recommendation to choose a region may vary depending upon how the connectivity follows your Anypoint VPC.

If the connection is private AWS peering, you need to create your Anypoint VPC in the same region as AWS. However, if it connects to your on-premises data center, you might have to pick a VPC region closest to your data center.

CIDR Block

 The most important part of the configuration CIDR (Classless Inter-Domain Routing) block can be calculated by exponential notation 2N ranging from 28 – 216. /24 is the smallest network subnet block that can be assigned for Anypoint VPC. (Total 256 IP Addresses), on the other side, the largest subnet can be /16 (provides 65,536 IP Addresses). It is important to size your VPC large enough to accumulate enough IP addresses to support zero application downtime.

 

While choosing an IP range, consult your Data Center Infra team to not conflict with the address space being used at the Data Center.

Considering two IPs for each worker instance to support zero-downtime deployments. MuleSoft recommended that sizing is to 10X your maximum number of expected apps to deploy per environment in the VPC.

 

Environments

You can choose multiple environments for each VPC, while the configuration is based upon the type of deployment. e.g., SIT, UAT, Test can be pointed to one VPC, and PROD can be pointed to another VPC.

Multiple environments can be picked for each VPC while configuration, based upon the type of deployment, 

If an environment is not selected, all applications deployed to the selected region will be associated with this Anypoint VPC.

NB: Don’t associate Anypoint VPC with a design environment. Apps can be deployed to the design environment only from Design Center and not from Runtime Manager.

 

Incorporating Business Groups within VPC

A VPC can be shared amongst various business groups within your organization. Therefore, MuleSoft recommends VPC should be created in the parent organization.

Anypoint VPCs are only vertically shared, i.e., A VPC can be shared to one of its business groups or can be shared from a business group to one of its child business groups.

Once shared, the reconfiguration of VPC, like changing the region, the environment, can be done by admins of associated business groups. In this case, the previous configuration is overwritten by the newly requested VPC configuration.

Creating firewall rules

When the Anypoint VPC is created, by default, four firewall rules are set. The practices can be reviewed and modified as per your requirements.

Firewall_rules

8081 and 8082 are listening to inbound traffic from anywhere to the VPC network. These are the default incoming HTTP and HTTPS port for requests to reach the CloudHub workers. They are by default configured while VPC uses MuleSoft’s shared load balancer, although they can be depreciated if you do not want isolated workers to be reached by public IPs.

8091 and 8092 ports are reserved by default for inbound connections within your local Anypoint VPCs. All within the organization and even CloudHub-dedicated LB allows you to access your workers using these IPs HTTP private port (8091) and HTTPS private port (8092).

You can open additional ports using firewall rules within your VPC, by clicking Add New Rule.

This article gives you insights to kick-off the configuration of your Anypoint VPC for safeguarding your CloudHub worker instances by creating required firewall rules and giving possible flexibility of connecting to internal on-premises or cloud assets.

Thanks for reading. Hopefully this will help all of you MuleSoft Developers to Isolate CloudHub Worker using VPN.

MuleSoft Composer for Salesforce

MuleSoft Composer for Salesforce

What is MuleSoft Composer?

 MuleSoft Composer — a quantum leap forward in bringing automation to the center stage, making it easier to discover insights on customers with almost no coding skills. If you’re a developer or work in IT, you may already be familiar with MuleSoft Anypoint Platform — the world’s #1 API integration platform. With Anypoint Platform, IT teams can securely integrate systems and unify data with reusable APIs to launch key business initiatives such as building connected customer experiences and automating business processes. Thousands of organizations rely on Anypoint Platform™ to deliver speed, agility, and innovation at scale.

The MuleSoft Composer is built to address the same challenge, but for a different audience: knowledge workers in Line of Business (LoB) who aren’t developers. Read on to find out why empowering non-developers to build integrations benefits everyone, the challenges that Composer solves, and the first solution to our tailored approach to making Composer available for everyone: MuleSoft Composer for Salesforce.

 

MuleSoft Composer for Salesforce

Your users’ day-to-day work probably spans many different systems. They’re using Salesforce (of course!), but they also use email and perhaps spreadsheets. Maybe your company also uses NetSuite for inventory management, Workday for human resources, Slack for team communication, Box or Dropbox for file storage… the list goes on!

These systems and applications neatly store all the data needed to function on their own, but our business processes are anything but siloed. If the NetSuite inventory isn’t also in Salesforce, your sales team needs to switch back and forth between applications. Not only is that slow, but it also increases the chance that data will be inconsistent across those applications.

MuleSoft solves this exact problem: unlocking data across applications to deliver connected experiences. But MuleSoft has traditionally been a developer tool, out of reach for most admins — and that has meant waiting for development resources to complete your high-priority projects.

We know that YOU, #AwesomeAdmin, are an innovator. With Salesforce’s declarative tools, you find creative ways every day to make your users more effective and help your company grow. MuleSoft Composer is built to break down data silos and automate integrations yourself with clicks, not code. And you’ll do all of this directly within Salesforce, where you already live.

    What you can do with MuleSoft Composer for Salesforce?

  • Build API integrations easily with clicks, not code — all inside Salesforce

MuleSoft Composer

  • Hit the ground running with a library of connectors and templates – Get started in minutes

MuleSoft Composer integration

  • Preview as you build connections and design with real data

MuleSoft Composer Integration

  • Monitor any errors with automatic alerts

MuleSoft Composer integration

What’s next for MuleSoft Composer?

 

In the future, MuleSoft Composer will be readily available for organizations not yet using Salesforce Customer 360 or MuleSoft’s Anypoint Platform. 

The collaboration of IT and business is set to enhance for a better tomorrow as LoB workers have been striving for the tools that can help them to connect and access data without codes and complete their high-priority projects without hassle. Mulesoft Composer is designed to fill this gap. 

 

Caelius Consulting is a one-stop-shop for MuleSoft’s Anypoint and Salesforce consulting.