Contact Free trial Login

Mule as MBean

Mule Runtime Engine versions 3.5, 3.6, and 3.7 reached End of Life on or before January 25, 2020. For more information, contact your Customer Success Manager to determine how you can migrate to the latest Mule version.

An MBean is a named managed object representing a resource in an JMX environment. You can easily deploy an MBean with Mule by taking the following steps:

  1. Create an MBean

  2. Create service descriptor

  3. Deploy MBean (as .sar) to application server

  4. Copy dependencies to the service’s classpath

This page describes these steps using the JBoss application server.

Creating a Simple MBean

To create an MBean, you need an interface and an implementation:

package foo.mbean;

public interface FooServiceMBean {
    public String getBar();
    public void start();
    public void stop();
package foo.mbean;

import org.jboss.system.ServiceMBeanSupport;
import org.mule.config.spring.SpringXmlConfigurationBuilder;
import org.mule.api.MuleContext;
import org.mule.api.context.notification.ServerNotification;

public class FooService extends ServiceMBeanSupport implements FooServiceMBean {

    public String getBar() {
        return "bar";

    public void start() {
        this.getLog().info("MBean being started");

        try {
            MuleContext context = new DefaultMuleContextFactory().createMuleContext
(new SpringXmlConfigurationBuilder("foo-config.xml"));
        catch(Exception e) {
        this.getLog().info("MBean started");

    public void stop() {
        this.getLog().info("MBean being stopped");

        try {
            if (context != null) {

            this.getLog().info("Done stopping Mule MBean Service!");
        catch (Exception ex) {
            this.getLog().error("Stopping Mule caused and exception!", ex);

The extension of ServiceMBeanSupport is simply to provide you more control over the API provided by JBoss.

Creating JBoss Service Descriptor

You must create a service descriptor and add it to to META-INF/. Following is a simple example:

<?xml version="1.0" encoding="UTF-8"?>
  <mbean code="foo.FooService" name="foo:service=Foo">

Deploying MBean to JBoss

Based on the examples above, your distribution looks like this:


Package the distribution either as a JAR, which you can then rename to a *.sar that you can eventually extract, or as a directory called <dirName>.sar.

Copy the Dependencies

Follow the steps below to copy the dependencies and complete the deployment:

  1. Copy your <dirName>.sar/ directory to JBOSS_HOME/server/default/deploy/.

  2. Copy all dependencies of Mule, such as MULE_HOME/lib//.jar to the <dirName>.sar/ directory

  3. Start JBoss. You will see the MBean appears in its MBean console.

Was this article helpful?

💙 Thanks for your feedback!

Edit on GitHub