Dynamic Mule Domain Projects

Written by Mir Musthafa Ali Pasha

Middleware Practice Head at Royal Cyber

Introduction

A Mule Domain project can be created to include selected connectors as shared resources, which can be reused from different Mule applications associated with this domain project.

Note: Mule applications can be associated with only one domain at a time.

Domain Projects allows the developers to,

  • Expose multiple applications within the domain via the same port.
  • Share the connection to Mule’s persistent storage.
  • Guarantee consistency between applications upon any changes, as the configuration is only set in one place.

Problem Statement

To create a dynamic Mule Domain project which can fetch the shared resources (HTTP and HTTPS listener configurations) based on the current environment and server name to be shared across all apps in the server. We want to maintain just one domain project for all runtimes present in all environments.

Creating a Mule Domain Project

1) On Anypoint studio, Click File -> New -> Mule Domain Project.

2) Create 2 Global element properties, 1 each for HTTP and HTTPS listener configs.

Note: Set the port as ${http.private.port} and ${https.private.port}

3) Create a Configuration Property specifying the rule to pick the *.yaml file based on the environment (mule.env) and server domain (mule.domain).

4) Define the yaml files based on the mule.env (dev, qa, uat, sfdcqa) and mule.domain (api, sys, batch1, batch2)

5) Create a Mule Project and configure the properties to use the current Mule Domain project by Right Click -> Properties -> Mule Project

Deployment Guide

  1. Export the Mule Domain Project as a Mule deployable archive and copy it to Linux VM using Winscp.
  2. Login to the dev_mule user using the switch user command.

    Command: $ su – dev_mule

  3. Navigate to the conf directory of the server.

    Command: $ cd %MULE_HOME%/conf

  4. Edit the wrapper.conf file to create an additional runtime property mule.env. Save and exit the file after editing.

    Command: wrapper.java.additional.23=-Dmule.env=dev

  5. Edit the wrapper.conf file to create an additional runtime property mule.domain. Save and exit the file after editing.

    Command: wrapper.java.additional.30=-Dmule.domain=sys

  6. Navigate to the bin directory of the server to perform a mule restart.

    Command: $ ./mule restart

  7. Copy the mule-domain-v1-1.0.0-SNAPSHOT-mule-domain.jar file to the respective server under domains directory.

    Command: $ sudo cp mule-domain-v1-1.0.0-SNAPSHOT-mule-domain.jar %MULE_HOME%/domains

  8. Switch to dev user and navigate to bin directory of the server to perform another mule restart.

    Command: $ su – dev_mule

    $ cd %MULE_HOME%/bin

    $ ./mule restart

  9. Navigate to logs directory and tail the mule_ee.log to verify the successful deployment of the mule domain project.

    Command: $ cd %MULE_HOME%/logs

    $ tail mule_ee.log

Summary

Here, we have demonstrated how the shared connectors work all through runtime of Mule domain projects. For more information, you can email us at [email protected] or visit www.royalcyber.com

Leave a Reply