Nav

Developing Applications for CloudHub

logo cloud active logo hybrid disabled logo server disabled logo pcf disabled

Mule applications that are meant for deploying to CloudHub may sometimes require that you do things a little differently than for applications that are meant to be deployed to an on-premise server. For the most part, the same Flow Elements and Global Elements apply in the same way, but there are some specificities that you must consider. Deployment Strategies covers the key differences between both deployment environments, this document lists a few best practices to employ when deploying to CloudHub.

The CloudHub guide, includes walkthroughs of basic concepts and Deploy to CloudHub examples to help get you familiar with the process of developing and deploying your applications in CloudHub.

Specifying an HTTP/HTTPS Host

If you employ any HTTP Connectors, define the Host address in a CloudHub configuration as 0.0.0.0. CloudHub routes requests from your application domain URL to the endpoint. If you deploy multiple workers, CloudHub load-balances incoming traffic automatically across these workers for you. As your application scales, work loads automatically distribute between your workers.

Providing an External HTTP/HTTPS Port

If your application requires an externally accessible HTTP or HTTPS port to receive messages, trigger events, or expose a web service or user interface, declare the Port using the reserved property ${http.port} or ${https.port}. On CloudHub, port ${http.port} or ${https.port} is assigned automatically by the platform services. Traffic on port 80 to your application domain’s URL routes to this port.

CloudHub only supports incoming traffic on port 80 of your application domain URL. To support routing to multiple CloudHub services over this port, you need to configure each with unique paths on the URL that is exposed. For example:


         
      
1
2
http://0.0.0.0:${http.port}/service/path/one
http://0.0.0.0:${http.port}/service/path/two

Deployment Strategy Flexibility

If you want to deploy a same Mule application via various different deployment strategies – such as to an on-prem server and on CloudHub – you should abstract some parameters of the application to application properties that you can set with different values in each case.

Create an application properties file named mule-app.properties in the src/main/app folder of your project. You need to do this whether you work in Anypoint Studio or another IDE and want to deploy to Anypoint Studio’s built in server. This allows you to define a local value for the variable http.port or https.port.

If you have other runtime settings that you want to configure differently when running locally, you may also place them in the application properties file and refer to them using the syntax ${propertyname} in your Mule application configuration. Each application can declare a set of environment variables when it is deploys to provide a different value when deploying on CloudHub. You can define these environment variables using the Runtime Manager Console or the Command Line Interface.

Logging

All log messages from your application are captured by the CloudHub logging service and available through the log search tool in the Runtime Manager console. If you wish to expose additional information in your logs for diagnostic or audit purposes, Mule provides a logger element for fine grained logging of message content.

On CloudHub, after you delete an application, your log data is no longer accessible through the console. CloudHub archives old log data for a limited period of time before being purged. This allows you to recover the data if needed. Open a support case at: https://support.mulesoft.com for more information.

Packaging Third-Party Libraries

CloudHub provides services in the platform that support connecting over many different protocols and transforming many data formats. All the standard Mule libraries are included and available to your application. If you have the need to include a different third party library, you can package that library in the <mule application zip>/lib folder of your application package. Any libraries that are packaged in your Mule application lib folder are available on the classpath to your application at run time.

Accessing Resources Behind the Firewall

When developing an application that needs to access resources from inside your firewall, you can configure a Virtual Private Cloud (VPC) to host your Cloudhub Workers and configure an IPSec tunnel to access your applications.

Accessing Third-Party APIs and Services

CloudHub includes connectors for many third party applications, such as Salesforce, NetSuite, Twitter, and others. Anypoint Studio includes a few of the most common ones out of the box for developing with CloudHub, and the Anypoint Connector DevKit documentation provides more detail on how to find and deploy these connectors with your application.

Secure Properties

Note that you can flag application properties as secure so that their values are not visible to users at runtime or passed between the server and the console. See Secure Application Properties for more information.

Adding a UI for Your Application

Applications deployed to CloudHub can have a web UI using HTML and JavaScript. The AJAX Module provides support for interacting with your application from the browser and provides support for serving up static content.