Author: Jeetan Madaan
Preface
This document will articulate the needs to learn the Mule 4 SDK, which is a successor to the Mule 3 DevKit and helps you extend Mule Runtime capabilities.
Use Cases
Modules enable reuse, offload complexity and deliver consistent behavior. As applications are being upgraded with cloud enablement & microservices for internet scale, redesign efforts can leverage Mule SDK.
SDK – Xml
Mule 4 introduces modularity as an implementation principle to mule apps, and provides an xml sdk that helps developers create custom modules. In Mule 3, Flow is a higher level construct, and Mule App can have several flows and subflows which can be organized into multiple files to improve code management, but in mule 4, multiple mule developers can create reusable modules which can be reused across several apps and can be downloaded as a dependency from enterprise repository.
Module – Hello Mule Extension
Create the Extension Project using the mule maven Archetype. Install the dependency in the local repository.
Test Module – Hello Mule Extension
It is quite important to enable the module integration in a mule app, and one of the ways is to create a Test Hello Mule Extension App using the Studio, and add the dependency to test the operations included in the module.
To keep it simple, we will just expose the app with http listener and invoke one of the operations exposed by the extension module, and we should see the payload set in the operation of the extension module.
SDK – Java
Mule 4 Java SDK uses an Extension API that interacts with mule runtime rather than using code generators, scaffolding to ease the connector development. Also Mule Runtime versions are backward compatible with the SDK versions.
Module – Hello Mule Extension Java
Create the Extension Project using the mule maven Archetype. Install the dependency in the local repository.
Test Java Module – Hello Mule Extension Java
We will create a Test Mule Application and import the Java SDK module as dependency. We will then test one of the operations, sayHi(String person) in the test mule app.
References
https://blogs.mulesoft.com/dev/howto/mule-xml-sdk/
https://docs.mulesoft.com/mule-sdk/1.1/xml-sdk#xml-sdk-basics
https://docs.mulesoft.com/mule-sdk/1.1/module-structure#components-2