Mule Kernel 4: Anypoint Studio

DZone 's Guide to

Mule Kernel 4: Anypoint Studio

Look at writing a simple application in an environment that we should know pretty well...Anypoint Studio.

· Integration Zone ·
Free Resource

In the last article, I described my attempts with writing Mule apps in IntelliJ for Kernel edition. With no luck. Here, I will focus on writing a simple application in an environment that we should know pretty well...Anypoint Studio. After that, I will deploy this application on the Kernel application server to test how it works. If you are interested in basic information about Mule Kernel 4, look at this article where I have revealed some basic news.

Anypoint Studio

The newest version of Anypoint Studio can be downloaded from here. If you have already installed Studio, I encourage you to compare versions. It happens that slightly older versions like 7.2.2 won't get upgrades to version 7.3. It is good to check this, especially when rapid development of this IDE is made.

Anypoint Studio is a platform for developing Mule applications. From version 7, however, it is only dedicated to enterprise runtimes. On the other hand, on one of the MuleSoft pages, I have noticed information that Kernel has or will have the support of Anypoint Studio.

Demo Application

The application will be a really simple one. HTTP listener will be accepting only GET and POST request on a single URI. Like in the diagram below.

The first operation will return static service's status. Below you can find the output.

"status": "UP",
"details": {
"serviceType": "http",
"status": "UP",
"statusCode": 200


It is a good practice to embed a health endpoint into an application. More on that, I have written in the following article.

The second operation will accept JSON input and produce from this an XML document. Response will look like below.

//your input here as an XML


You can find the complete code on GitHub. If you would like to do it on your own, please follow closely this chapter.

Project Creation

In Anypoint Studio, you may create a new Mule project. First, select runtime. Although we are developing an application for Kernel runtime, we should select EE in studio.

API Preparation

We will use APIKit to generate flows. In order to do it we need to prepare RAML API specification. Below you can find a really simple one, but sufficient for the purpose of this demo.

#%RAML 1.0
title: Health Service
mediaType: application/json


Once we have this file in src/main/resources/api you may click the file and select Mule > Generate Flows from REST API.

Warning — EE Namespace

By default, APIKit will generate error handling with Transform Messages components. In order to use it on Kernel runtime, we need to refactor it to Set Payload and Set Variable processors.

Here is a sample transformation prepared for APIKIT:BAD_REQUEST error

    <ee:set-payload><![CDATA[%dw 2.0
       output application/json 
       {message: "Bad request"}]]>
    <ee:set-variable variableName="httpStatus">400</ee:set-variable>

As you can see transformation set a simple JSON body with message property and variable httpStatus that will be used to set HTTP status returned to the client. In the example 400 error code, we need to rewrite it using Set Payload and Set Variable components like below

<set-payload value='#[output application/json
{message: "Bad request"}]' doc:name="Set Eror Payload"/>

<set-variable value="400" doc:name="Set HTTP status" variableName="httpStatus"/>

Methods' Implementation

So far, we should have an application, API, and Mule configuration file with generated flows. We should have two private flows:

  • get:\health:health-config
  • post:\health:health-config

We need to omit all component that are in EE namespace. Therefore I will use Set Payload processor to perform simple transformations.

EE Processors

When you drag any processor form EE namespace like Transform Message you won't be able to run that application on Kernel runtime. You need to remove that processor and take care of namespaces in Configuration XML.
Example to remove:
and a corresponding line form xsi:schemaLocation
http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd

In Set Payload, I have set the following value:

Anypoint Studio — DataWeave editor

As of version 7.3 of Anypoint Studio new editor has been introduced for writing DataWeave expressions in other components like Set Payload, Logger etc. It will look like a standard Transform Message's editor — you can see it above.
To enable that view you need to click button f(x) next to the field.

As you can see, I have specified, using output directive, that I expect JSON. In the body section, I have provided a structure that will be translated into an appliction/JSON object.

This time in Set Payload I have provided the following expression:

output application/xml
"health": payload

As a result, I will have an XML document with a root element called health and sub-elements coming from input request.

Kernel 4 enablement

In order to make sure that you are making your application for Kernel runtime you should edit mule-artifact.json file.

In the JSON body, you need to add a property called requiredProduct like in the example below.


According to the documentation, MULE value means that application can be deployed on the Kernel runtime. When we specify MULE_EE that means that application can be deployed on Enterprise runtime.


In order to deploy the application you need to build it first. You may do this using following command

mvn clean install

Deployable artifacts are now packed into a JAR file. As a result, in the target directory, you will find jar file instead of a zip archive.

You need to move that file into an apps folder of your runtime. In your runtime, you should see the status of deployment like:

Now you are ready to test that.


Developing application for Kernel runtime is rather straightforward but you need to keep in mind that currently, Anypoint Studio does not sport that runtime. However, we may develop an application using EE runtime for now.

There are some things that you need to remember such as:

  • not using enterprise components like Transform Message
  • remove ee namespace
  • APIKit use Transform Message by default for error handling
  • required product needs to be set in mule-artifact.json
integration ,mule 4 kernel ,anypoint studio ,tutorial

Published at DZone with permission of Patryk Bandurski , DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}