Arguably, one of the cooler things you could do in a Mule project is to write your own Mule Connector. These custom objects are variously referred to as Connectors, Components, Plugins or Extensions.

Done right, this will allow other developers to drag your custom connector from their Mule Palette in Anypoint Studio and drop it into their own Mule flows where they can then configure it for their purposes, just like in the flow below.

 

 

The above flow, contains some of the usual suspects in the Mule Connector / Component arsenal:

  • Scheduler — initialises a flow at a set interval
  • Set Payload — sets the Flow’s payload to a given value
  • Set Variable — initialises or updates a variable with a given name & value
  • Transform — generates content using Dataweave scripts
  • HTTP Request — makes a call to some external url

By writing a custom connector, you can bake specific reusable functionality into your own flows and allow others to access this functionality as well.

Of course, this begs the question. When should I consider creating my own custom component?

In truth, the answer is, ‘Hardly ever.’

For instance, if you have a piece of bespoke Java code, whose functionality you would like to invoke, you might be tempted to wrap this in a Mule component. Frankly, this would be overkill. Mule already provides a Custom Java component out of the box. This allows you to build predefined Java functionality right into your flows without having to do any bespoke development of your own.

Same goes for scripting (E.g. Groovy). Mule already provides the components you need for this type of bespoke functionality.

Not to mention the fact that there is already very little you can’t accomplish using the Mule’s oh-so-powerful Transform component and Dataweave.

In fact the only time you really need to reach for a Custom Connector is when you need a bespoke component that will aid future developers. Custom components are not for the benefit of end users at Runtime; they are there to make life easier for your development team at Design-Time.

Custom Connectors are also ideal for tech vendors who want to offer Mule developers a bespoke way of integrating with their own products. Even then, in most cases, many of these products expose their functionality via well-trodden pathways like:

  • HTTP(S)
  • JMS / AMQP / MQTT
  • JSON/REST
  • SOAP/XML
  • JDBC/SQL

In most cases, Mule already offers generic components that can connect to any and all of these transports and protocols out of the box.

Truth be told, I have only had one occasion to implement a Custom Component in a commercial context. In this scenario, my client had a specific logging strategy that required strict governance. This multi-national client needed to enforce said governance on all their Mule developers globally and, to that end, they requested a bespoke Logging component that enforced the rules while still offering developers limited flexibility to customise their logging where needed.

So what skill-set is required for custom component development? Solid Java skills for a start. You are not writing Mule flows here; you are writing Java code. Understanding of Inheritance and Interfaces is a must. Beyond that, you will need a solid understanding of Java Annotation. Anypoint Studio makes extensive use of Annotations to inform the IDE about your component. Solid Maven experience and knowledge is also a big plus for this type of undertaking.

If you get the opportunity to develop such a component, grab it! It’s super-cool to get a glimpse of this powerful product under the hood — and it is an opportunity you probably won’t get again in a hurry.

As always, you will encounter hurdles and technical gotchas along the way. Expect this. You are, after all, taking the path less traveled by. Custom component / connector development is not for the faint-hearted; it calls for a true Mule Whisperer.

For those lucky few who have both the skill and the opportunity to develop such a component in a commercial context, I wish you all the best.

May you rise to the challenge!

 

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>