You are viewing an older version of this section. Click here to navigate to the latest version.

Your First Cloud Connector

This tutorial will help you get started building Mule Cloud Connectors and Modules with Mule DevKit. The sections below demonstrate how to build a simple cloud connector and integrate it into your Mule ESB application.

This document will help you:

  • learn basic DevKit concepts

  • create a basic cloud connector with a Hello World operation

  • import your new cloud connector into Mule Studio

  • use the new connector in your Mule ESB application

Creating a Cloud Connector

The first step in this tutorial involves creating a Cloud Connector. Mule DevKit makes it easy to get started by generating a connector for you.


To complete this tutorial, you must be proficient in Java programming and understand how to use the command line, Maven and Eclipse or IntelliJ.

Ensure that you are using Maven 3 and JDK 6. (Current releases of DevKit do not support JDK 7.).

Creating Your Connector

Complete the following steps to initiate generation of your first connector.

  1. Type the following command in your Windows Command Prompt or Unix shell:

     $ mvn archetype:generate \ -DarchetypeArtifactId=mule-devkit-archetype-cloud-connector \ -DarchetypeVersion=3.3.1 -DgroupId=org.hello -DartifactId=hello-connector -Dversion=1.0-SNAPSHOT \ -DmuleVersion=3.3.0 -DmuleConnectorName=Hello -Dpackage=org.hello \ -DarchetypeRepository=
  2. The command inherits the following parameters which you can change depending on your particular connector:

    Name Description


    name of your connector


    Java package for your connector classes


    Maven artifactId of the connector


    Maven groupId of the connector

  3. DevKit prompts you to ensure that the parameters listed above are correct. Type Y, then press enter to confirm.

  4. DevKit generates a project for your connector in the hello-connector directory

Importing the Connector into Your IDE

After creating your project on the command line, you must import it into your integrated development environment (IDE). The following outlines the import procedure using Eclipse; if you use IntelliJ, consult Writing Extensions in IntelliJ


Because DevKit generates your new cloud connector as a Maven project, you must have Maven tooling for Eclipse installed. Follow the m2eclipse installation guide to install Maven tooling.

Importing your project

  1. If you haven’t already done so, start Eclipse, then set up a workspace for your cloud connector. Be sure your workspace does not contain a space in the directory path.

  2. In the workbench view, select File > Import …​

  3. In the dialogue box, select Existing Maven Projects from the Maven section.


  4. In the new dialogue box, navigate to, then select, your new cloud connector project.


  5. Click Finish to import the project into your workspace.

  6. The Eclipse-Maven integration imports the project and downloads all the required libraries; this may take several minutes. See image below for an example of an imported project.


Updating your project

The Maven build automatically generates the Mule schema and namespace handler for your cloud connector. Maven tooling for Eclipse, however, does not perform the full build every time you save the project. As a consequence, you must manually update your project every time you add or remove methods to your cloud connector class.

Right-click the cloud connector project. Then, from the Maven submenu, select Update Project Configuration (see image below).

+ UpdateProjectConfiguration-1

Your First Connector Operation

An operation is simply a DevKit method call with annotations. Connector operations wrap connectivity to external systems, or wrap some logic into a simple call that your Mule ESB application can make. The following sample code executes a simple operation which simply changes the payload to Hello Joe.

 * Says hello to someone.
 * {@sample.xml ../../../doc/Hello-connector.xml.sample hello:say-hello}
 * @param name The name to say hello to.
 * @return The hello message.
public String sayHello(String name)
    return "Hello " + name;

The @Processor annotation dictates that this method becomes a message processor in a Mule ESB flow. DevKit turns the "String name" into an attribute that can be specified as a parameter to the message processor (see code below).

<hello:say-hello name="Joe"/>

Mule DevKit also enables you to substitute expressions into the parameters to your operation, so you can extract data from the payload (see code below).

<hello:say-hello name="#[]"/>

Documenting your Connector

You are required to document each operation your connector performs. This ensures that your end users understand how to use your connector correctly. You must also include a sample XML snippet in the documentation that DevKit generates for your connector. To do this, open the hello-connector/doc/Hello-connector.xml.sample, then add the following code.

<!-- BEGIN_INCLUDE(hello:say-hello) -->
    <hello:say-hello name="Joe" />
<!-- END_INCLUDE(hello:say-hello) -->
To disable the documentation, add -Ddevkit.javadoc.check.skip to the command line whenever you run Maven.

Building Your Connector

To build the connector, go to the command line, then run the following command:

 $ cd hello-connector$ mvn package

DevKit’s Maven plugin builds several artifacts in the target directory (see table below).


connector JAR

Mule plugin which you can drop into the /plugins directory in Mule standalone.


auto-generated installation instructions, javadoc, and Mule API docs for your connector

Using Your Cloud Connector

Complete the following procedure to import your connector into Mule Studio.

  1. In Mule Studio, access the Help menu, then select Install Software.


  2. Click the Add button to add an update site.

  3. In the Name field, enter the name, Hello Connector.

  4. Enter the full path to your connector, prepended with file:/", then click OK.


  5. Select your connector from the update site.


  6. Follow the steps to accept the license, then restart Studio.

  7. Studio makes your new cloud connector available for selection in the Studio palette.

Next Steps