November 22 2019


Reuse is the catalyst that turns the vision of API-led connectivity into a reality. In the context of MuleSoft, reuse can come in many different forms:

  1. APIs
  2. Frameworks added as a jar/maven dependency
  3. Pre-packaged project templates within Exchange, which could then be imported into Anypoint Studio

The standard approach I always follow when engaging with my customers is identifying common reusable frameworks that can be used across use cases. For example, error-handling framework, logging framework, notification framework, etc. The goal is to standardize these frameworks, to make them reusable and easy for developers to incorporate into their use cases, without having to implement from scratch. One tool that helps me help my customers in building those frameworks is the XML SDK

Advantages of the XML SDK:

  1. They are reusable by design.
  2. It is a powerful way of creating custom modules by packaging Mule components (that are used in Mule flows) together. 
  3. Easy to manage, maintain, and support, just like Mule applications.
  4. Easy to read/implement because the constructs are the same as Mule flows and developers don’t need to know any programming languages.

In this blog post, I show how to modify the error-handling logic that was demonstrated in one of my previous blog posts around Anypoint MQ, using the XML SDK. To understand the basics of XML SDK, please see this.

Quick recap on the error-handling logic

XML snippet of the error-handler logic:

As you can see, in the error handler block, there are several steps involved:

  1. Transform message with additional meta-data
  2. Logging
  3. Publishing to error-queue using Anypoint MQ Connector
  4. Acknowledging the message using Anypoint MQ Connector

The above set of steps is actually a simplistic implementation. In reality, it is common to have more orchestration and logic involved. If there are additional projects that implement a similar pattern, then there is significant value in externalizing the logic as a custom module using XML SDK.

For step-by-step instructions on how I implemented the module and the source code of the project itself, please see this.

XML Snippet of the ErrorHandler Module implementing the error-handler logic:

In closing, I would like to leave you with the following images, the one before and the one after implementing XML SDK module:


The XML SDK module can just be reused by any other project by simply adding the connector as a dependency from Exchange without having to rewrite or copy/paste the logic.

For more information on how to use Anypoint Platform, visit our developer tutorials site.