Webinars

Metl includes a prepackaged component library for everyday use but some users may require unique functionality. This can easily be achieved with custom components. In this article I will walk through the steps required to create your own custom Metl component

1.0 Overview

Metl is an open source, lightweight, web based integration tool that supports the creation of custom components. Metl comes with a large set of prepackaged components, however, if a unique need arises, custom components can be created to implement specialized needs. Building custom components is very straight forward. The basic steps are as follows:

Create a Java Project – The java project will contain the source code and related files for the custom component

Package the component – Files in the java project are packaged into .jar files or .zip files for deployment.

Deploy the Component – Provide the packaged component to Metl via uploading it directly to the running Metl instance or loading it into a maven repository accessible to that Metl instance.

This will describe the steps required to create a custom component that uses Pushover, a cross platform notification application capable of varying levels of priority. The goal of this component was to integrate with our support center platform to send an emergency notification in the result of a missed support call. The flow utilized several standard Metl components but this will focus on the development steps for the custom Pushover component.

2.0 Creating the Java Project

The Metl engine and its prepackaged projects are built in Java. To create the custom component, first create a new Java project to hold the source code and related files. The project needs a dependency on the metl-core library which is available from the JumpMind maven repository here. The project structure for this custom component is shown below.

The project requires the following parts:

plugin.xml – Used to create the component definition.

ui.xml – used to create the UI definition.

One or more java class(es) – Used to implement the component methods.

3.0 Creating the Component Definition

The component definition is created by writing a file called plugin.xml. This xml file needs to conform to the components.xsd file which can be found here. This file determines parameters such as the component name, and component settings. The basic component definition is defined as such:

The id defines the component name. The input and output message type can be set to one of four values, one of the three message types, or any. In Metl data flows between components through a series of messages that are generated and consumed by each component. The three message types are as follows:

Model Based Message

Text Based Message

Binary Based Message

In this component, we chose to allow any input and output message type to keep the component generic and flexible.

Settings for the custom component are also defined in the plugin.xml file. A small sample of some of the settings configured are shown below:

Each setting consists of an id, required field, and a type. Initializing required to true in the plugin file will make that setting necessary to run the component. The three setting types used in this component are choice, text, and multiline_text. The type of setting will determine how said setting takes input in the Metl interface.

The choice type utilizes a drop-down menu to allow users to choose from a limited set of values defined in the plugin.xml file.

In this case the choice is for a sound chosen from a set list given by pushover to use when delivering a message.

The other two setting types used were text and multiline text. Both settings are represented in Metl by an editable text field. The choice between the two will depend on the use case.

In this component both Token and User Key are represented as text fields since they are both relatively short strings generated by Pushover. Message is a multiline text field allowing for longer inputs. The red asterisk next to a setting indicates that it is a required field.

4.0 Creating the Component UI Definition

The UI definition is created in a file called ui.xml. In this simple component, we chose to use the standard Metl component UI but a custom UI can also be created.

5.0 Implement the Component

The next step in creating the component is implementing the required methods in the component's Java class. In this example, the class implemented the IComponentRuntime and extended the AbstractComponentRuntime class.

The complete list of defined methods is available at the link above but for this simple component we only implemented two.

Start – The method executed when the flow is started.

Handle – The method executed when the component is given an input message.

This start method created variables defined in the plugin.xml file and initialized them based on values input by the user in the Metl console.

For this component, we wanted the ability to send a message created or retrieved by other Metl components so we utilized the TextMessage input message type, setting the message variable created in the start method to the value of the input message if applicable.

6.0 Package and Deploy the Component

Once the component is ready for deployment it’s time to upload it to your Metl instance. Since this component was packaged into one .jar file, we will upload it directly into a running Metl instance for simplicity. To upload the component directly to the running Metl instance navigate to the Admin tab and select Plugins then click the Add button

In the popup window click on the Upload tab and fill in the required fields with the Group, Component name, and Software Version.

Click the upload button and navigate to the components class file. Once the class file has been uploaded, click Add to finish uploading the custom component to the Metl instance.

With your custom component now deployed in Metl, you can add it to flows and begin benefitting from its unique functionality.

Jacob is an intern at JumpMind working on both Metl and SymmetricDS. He is a computer science engineering student at The Ohio State University graduating in Spring 2020. He is a member of The Ohio State University Marching Band and in his free time enjoys PC gaming and building as well as rock climbing.