Migrating Devkit Connectors to Mule 4 SDK

Mule is a lightweight integration runtime engine that powers Mule applications. Mule applications receive events, process them and route them to other endpoints, and Mule Runtime defines the rules on how event data is handled in each application.

The role of Connectors is to facilitate the integration of Mule applications with third-party APIs and standard integration protocols. These are the elements which receive or send messages between Mule and an external source.

MuleSoft already has more than 160 free, off-the-shelf connectors for some of the most frequently used integrations, along with a set of premium connectors like SAP, SalesForce, Siebel etc. These connectors will be migrated for Mule 4 by the companies that originally developed them, such as Coforge.

For all other systems, often users develop their own custom connectors to enable their integration with Mule and this is where an understanding of how to migrate to the new Mule 4 environment will be needed.

Mule 3 Devkit vs Mule 4 SDK

Up to now, to develop these custom connectors users would use the Anypoint Connector DevKit (DevKit), which is available for Mule 3.x Anypoint Studio as a plugin. DevKit is an annotations-based tool, with a wide set of available annotations to support its features. It also includes connector packaging tools.

Mule 4 uses Mule SDK to create custom connectors. Unlike Devkit, Mule SDK is not a code generator. It is rather a plain extension mechanism. Mule SDK also adds support for features like Transactions, Request-Response message sources, Dynamic configurations, Routers, Non-Blocking operations, Classloading isolation etc.

In Mule 4, Studio 7.x comes with Mule SDK already installed, however it only supports Mule 4.x connectors (and projects in general), because the structure of the project, export format, xml and scripting language are different from Mule 3.x.

Users must migrate Mule 3.x connectors to Mule 4.x manually, before they can be used in Studio 7.x.

How to migrate a Devkit Connector to Mule SDK:

A Mule 4 upgrade should be approached as a migration project. To migrate an existing Devkit Connector in order to be compatible with Mule 4 SDK, the changes below, at high level, need to be incorporated into the connector code base.

Update pom file, to enable the Connector as Mule 4 extension

  • Update Packaging element


  • Update parent element


Folder structure

The typical folder structure for Mule 4 Connector will be:

  • <Module>/api
  • <Module>/internal

Update Annotations and Params Classes

Remove/Add/Replace Classes w.r.t Mule 4 SDK

Mule 3.x Classes Action Mule 4 Replacements
org.mule.api.annotations.Config REPLACE  org.mule.runtime.extension.api.annotation.param.Config
org.mule.api.annotations.Connector REPLACE  org.mule.runtime.extension.api.annotation.Extension
org.mule.api.annotations.display.Path REPLACE org.mule.runtime.extension.api.annotation.param.display.Path
REPLACE org.mule.runtime.extension.api.annotation.
org.mule.api.MuleContext REPLACE org.mule.runtime.core.api.MuleContext
org.mule.api.context.MuleContextAware REPLACE org.mule.runtime.core.api.context.MuleContextAware
org.mule.api.annotations.Processor REMOVE  
org.mule.api.annotations.param.Default REPLACE Attribute(defaultValue) of Optional
@Optional(defaultValue =
@Connect REMOVE  
@Disconnect REMOVE    
@ValidateConnection REMOVE  
@ConnectionKey REMOVE  
@ConnectionManagement REMOVE  
@Handle REMOVE  
@Handler REMOVE  
@RefOnly REPLACE @ExpressionSupport(NOT_SUPPORTED) and
ConnectionException REPLACE org.mule.runtime.api.connection.ConnectionException
ConnectionProvider REPLACE org.mule.runtime.api.connection.ConnectionProvider
OnException REPLACE org.mule.runtime.extension.api.annotation.OnException
TestConnector REPLACE org.mule.runtime.module.extension.
@org.mule.api.annotations.TestConnectivity   REMOVE  
@org.mule.api.ConnectionExceptionCode REPLACE org.mule.runtime.api.metadata.resolving.FailureCode
org.mule.util.IOUtils REPLACE org.mule.runtime.core.api.util.IOUtils
Operations ADD org.mule.runtime.extension.api.annotation.Operations
Configuration ADD org.mule.runtime.extension.api.annotation.Configuration
Connection ADD org.mule.runtime.extension.api.annotation.param.Connection

Interested in MuleSoft? Get in touch

Organise import statements (Remove old APIs and/or Add new APIs)

  • Remove All classes within Package org.mule.api

Refactor Class(es) into multiple classes as per basic model structure of Mule 4 SDK

  • Add *Extension class with below annotation at class level:

      @Extension(name = "azure-storage")


      @RequiresEnterpriseLicense(allowEvaluationLicense = true)

  • Add below annotation for the processor methods

     @MediaType(value = ANY, strict = false)

Unit Tests

  • Override getConfigFile() method to load the operation flow
  • Test Class Extends MuleArtifactFunctionalTestCase
  • Test Class name should be *Test*.java

Dependency software and versions:

     Mule runtime | 4.1.0
     Mule SDK | 1.0.0
     Java | 1.8
     AnyPoint Studio | 7.1.0
     Maven | >3.3.9

If you would like to find out more about Mule 4 and how you can migrate your connectors and projects to the new version of MuleSoft's Anypoint Platform, do give us a call at +44 (0)203 475 7980 or email us at Salesforce@coforge.com 

Other useful links:

Mule 4 and Studio 7 – a bird’s-eye view of what’s new

API Recipes with MuleSoft Anypoint Platform

MuleSoft Integration Services