Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Visually Orchestrate Your Java Code Using Intamerge Community Edition

DZone's Guide to

Visually Orchestrate Your Java Code Using Intamerge Community Edition

In this article, a developer explains a free to use tool he created to help orchestrate and integrate Java projects into coherent software.

· Integration Zone ·
Free Resource

The new Gartner Critical Capabilities report explains how APIs and microservices enable digital leaders to deliver better B2B, open banking and mobile projects.

Intamerge is a new visual Java product that aims to be a kind of Swiss army knife for developers, integrators, testers, and any technician who needs to wire up disparate bits of Java together to create new solutions.

First look at Intamerge Community Edition

The concept is simple. Take a bunch of Java code or libraries and turn them into widgets that can be visually wired together to create solutions, conceptually something like this sketch illustrates:

Conceptual sketch of a Java orchestration

Many of us developers and technical consultants love playing with Legos. We love how you can have a catalog of colorful components that can be easily clipped together to produce a design such as a vehicle or animal or anything that one’s imagination fancies.

My personal Lego collection is carefully organized and sorted by component so I can quickly access the pieces I need to solve a Lego challenge.

During my 30 years of tinkering with software, I’ve dreamt many times of having the software equivalent of Legos. A system where I could build up a library or palette of Java "gadgets" and then when tasked with a project I could just plug those gadgets together to produce a new product or solution. But, more than that, I dreamed of a system that could be easily rewired as my requirements and needs changed.

So the concept could be illustrated with this sketch:

Conceptual sketch of a palette of Java gadgets used to create an orchestration

Eventually, I decided to get on with it and write such a system and the Intamerge product was born. The product is called Intamerge Community Edition and can be used freely without limit. You can download it from here.

A key concept behind this product is to try and build up a community of developers who will contribute Java gadgets to the Intamerge Plugin Store. I've already put two open source plugins in the store which I've licensed under AGPLv2 and that's a license that other developers can use as well. We're also open to companies wanting to provide commercial plugins simply because we want our Plugin Store to end up covering all possible Java gadgets known to humanity.

The following screenshot tells the story nicely. It shows a solution built-up on the canvas from a bunch of Java gadgets. You can see the palette of Java gadgets on the right-hand side. We call them Elements and there are two types of Elements - Components and Connectors. We call the designer canvas a "Map," as it maps out your process. You can have as many maps as you want and you can interconnect them to build up more complex processes.

An orchestration or "map" in Intamerge

Your bits of Java code - your Java gadgets - are wrapped up as Connectors or Components. That's easy to do and I’ll show you how later. Basically, you stick them in jars and import those into the Intamerge engine. It doesn’t use anything heavyweight like OSGI. It’s all fairly plain Java, but it is heavily Spring based. You don’t even need an IDE to do any of this.

Once you have wrapped your Java stuff into Connectors and Components, Intamerge will discover them via its ClassLoader. They will then appear automatically on the palettes as you can see in the screenshot. You can then drag and drop them onto a canvas and wire them together to make up your solution.

An Intamerge palette of Connector elements

I once worked for an organization where we had to rapidly respond to unique requirements coming in from very different clients. Our solution was a portal but we had to rewire our business logic to fit each customer. After a while, I decided to host the business logic in an enterprise service bus so that I could easily wire up new solutions for each customer and make the most of the code we already had. It worked great, but the wiring all had to be done in XML and there was no visual palette that I could use to build up my library of code. It was also difficult to organize and manage the individual ESB integrations. I've addressed all of that in Intamerge and now I have a place where I can collect all kinds of Java and I'm able to wire it up to make new solutions.

Key Takeaways

  • You can visually prototype java solutions by orchestrating your Java code in the free Intamerge Community edition engine.

  • Any code can be easily hosted in Intamerge as a visual component that can be connected up to any other code in your palette

  • You can build up a library of Java functionality on a visual palette that you can then drag and drop and rewire into any solution from within Intamerge.
  • Intamerge is the first integration engine to have an App Store concept around which a community of developers can grow and create plugins for Intamerge.

Let's Build Up an Example Solution

Let's cover two things in this article. First, let's build a solution using out of the box Intamerge components. After that let's take a quick look at how you can add your own stuff into Intamerge to carve it into the utility knife that suits you personally.

We can't go into all the detail in this article, but if you want to dig in a bit more there are tutorials and other helpful documentation here.

Installation

The product itself is just a war project, an ordinary Java web project that runs on Tomcat or Jetty. You can use the installers on the download site, or just deploy the war yourself.

Once you are up and running you can then add new solutions by creating maps and organizing those maps in folders so you can keep it tidy. Maps are the Intamerge name for the canvas on which you drag and drop an aggregation of components and connectors and wire them up into a solution. Your solution can be made up of one or more maps and you can have as many of those solutions in a single engine as you want.

The Example

So, for our example, let’s set up a solution that watches for a file to appear on the filesystem. When the file is found, let's throw up a big alert message to tell us its there. Ok, it's a pretty basic elementary solution but its just an example and it's an idea that can develop into something more useful. For example, you could wire it up to an SMS sender (anyone volunteering to write that plugin?) and get a message on your phone when the file is ready. Or you could reformat the file into HTML and present it as a web page (there’s an Intamerge connector for that already). Maybe you can extract useful data from the file and send that to a phone as a summary.

So here is a sketch of what we want to achieve:

An example process

And here it is in Intamerge:

An example process implemented in Intamerge

We've dropped the File Input Connector (which looks for files and the Console Connector onto a map), Javascript, and the Console Connector onto the map and simply wired the elements together so that when a file is found, a message will be thrown up onto the console. The console is your Intamerge user interface in your web browser, from where you are configuring Intamerge. We added a bit of JavaScript in-between so we can customize the message that we want appearing on the console. There are different ways to do it, but let's use JavaScript to illustrate how you can also orchestrate bits of JavaScript, not just Java.

The Javascript looks like this:

var filename = message.readPropertyValue("filename");
filename + " has appeared in the filesystem";

On the map, you would enter this by clicking on the JavaScript component to access and edit its properties, finding the "javascript" property and pasting in the code:

Set a message using Javascript

So, you can see, we simply take the filename which is given to us by the File Input Connector as a piece of metadata known as a property, and we then output a String with our message filename + “ has appeared in the filesystem";. 

Once the map is drawn out, we save it and then we can run it.

Nothing happens until the file is created, so we create the file and as soon as the file is created our little Intamerge solution detects it and throws up a message on our browser:

A message pops up in our console

It shows up as a red alert because that's the default setting, but you can check out our documents and tutorials to figure out how to change that.

Now Let's Look at How You Can Wrap Your Java and Add it to the Palette

Ok, so that was a very elementary solution, but it's clear already that you can build up your palettes to contain anything that can be wrapped in Java and then build up all kinds of solutions graphically. The next question on any developers mind would be how easy is it to add Components and Connectors to Intamerge?

As I mentioned earlier, we are building up a Plugin Store of Components and Connectors (i.e. Elements) that people can download into their Intamerge instance. A plugin is actually just a jar and it contains any number of Components and Connectors.

So, for example, there's an HL7 Plugin jar that contains an HL7 Input Connector (i.e. something that acts as a server and listens for messages on the HL7 protocol), an HL7 Output Connector (i.e. something that acts as a client and sends messages to HL7 servers), and an HL7 acknowledgement generator component.

Your plugin can have any number of Components and Connectors but it should have a consistent theme, such as "HL7" in the example I mentioned.

There’s also a very useful TCP and HTTP plugin. You might be inspired to create an ImageMagick plugin, a Paypal plugin, a Dropbox plugin, etc..

Inside your jar you will have a Java wrapper (it's a simple Spring bean class) that wraps your code to make it into a Component or Connector. This Spring bean has a simple method that is called by the map when it needs to call your Component.

Intamerge Components are asynchronous. They sit around idle until a message arrives from an upstream (previous) element. When a message arrives, their processMessage() method is invoked by the Intamerge engine's message dispatcher. The Component then does "stuff" with the message and sends out a resulting message to the downstream (following) elements.

package net.esb.entity.element.component;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import net.esb.context.IMapElementContext;
import net.esb.entity.common.ElementStartException;
import net.esb.entity.common.ElementStopException;
import net.esb.entity.common.EntityStartException;
import net.esb.entity.common.EntityStopException;
import net.esb.entity.element.component.AbstractMapComponent;
import net.esb.message.IMapMessage;

@Component
@Scope(value = "prototype")
public class MyPluginComponent extends AbstractMapComponent<MyPluginComponentDefinition, MyPluginComponent>  {

@Override
public Object processMessage(IMapMessage message, IMapElementContext context) throws Exception{

String payloadStr = ((null == message.getPayload()) ? "" : message.getPayload().toString());
message.setPayload(payloadStr + " Some appended text here");

return message;
}
}

The processMessage method receives a Java object from the previous element. The engine has a dispatcher that runs behind the scenes and it takes that output object (or set of output objects) from the previous Element and puts it into an Intamerge IMapMessage object which has a payload member holding the object. The purpose of the IMapMessage is that not only does it hold the payload, but it also carries context. That context includes any kind of Java properties you want to add to it. Those properties can hold any kind of Java object.

Let's have a quick glance at some of the methods in IMapMessage:

package net.esb.message;

import java.util.Map;
import java.util.UUID;

import net.esb.dispatcher.RequestToken;

public interface IMapMessage {

/**
 * Get the payload being transported through the processor chain in this message
 * @return the payload
 */
Object getPayload();

/**
 * Replace the payload
 * 
 * @param payload input payload
 * @return output payload
 */
IMapMessage setPayload(Object payload);


/**
 * Add a property to the properties map
 * @param key the key
 * @param value the value
 * @return the message so you can chain
 */
IMapMessage writeProperty(String key, Object value);

/**
 * Helper method that returns a property as a String
 * using its getValue().toString() method.
 * @param key the key
 * @return the desired property's value as a string
 */
String readPropertyValueAsString(String key);

/**
 * Helper method that returns a property value
 * @param key the key
 * @return the desired property
 * @param <T> type of property value
 */
<T> T readPropertyValue(String key);


}

Your processMessage method in your Element receives the IMapMessage and then it can do anything and call anything - it can call any Java you have.

This is how simple it is to convert your existing code into an Element that can be used in Intamerge - you just need one of these Component beans to wrap your code.

The processMessage method finally returns a result - and that result can be any kind of Java Object. The dispatcher will then take that object, stick it into an IMapMessage and then it will pass it on to the next element.

The signature for a Component looks like this:

@Component
@Scope(value = "prototype")
public class MyPluginComponent extends AbstractMapComponent<MyPluginComponentDefinition, MyPluginComponent>  {}

This gives away a few more details that are worth knowing, all of which can be found if you read the documentation.

The first thing to note is that every Component extends AbstractMapComponent. By extending AbstractMapComponent, there’s less work to do to complete your Component. At the least, all you will want to do is override that processMessage method and we think that is pretty easy to do.

Plugin Definitions

You will also see that a Component has a corresponding Component Definition class. The Component Definition provides details on the properties of the component (i.e. settings that can be applied to it from the front-end) and it provides the path (for a classpath resource) to the icon that is displayed. Think of the definition class as metadata to go with your Element. This metadata is used by the JavaScript front-end to display the Element on the palette.

package net.esb.entity.element.component;

import org.springframework.stereotype.Component;

import net.esb.build.BuildInfo;
import net.esb.entity.common.Colors;
import net.esb.plugin.IPluginInfo;
import net.esb.plugin.PluginInfo;

@Component
public class MyPluginComponentDefinition extends AbstractComponentDefinition<MyPluginComponentDefinition, MyPluginComponent> {

private static final long serialVersionUID = 1L;

final String name = "My Plugin name";
final String url = "entityimages/esb_engine/smileyface.png";

final String description = "This is a description of what my plugin does";

IPluginInfo pluginInfo =  null;


public MyPluginComponentDefinition() {
super();
registerProperties();
resolveEntityBeanProperties();
}

void registerProperties(){
}

@Override
public String getName(){
return name;
}

@Override
public String getUrl(){
return url;
}

@Override
public String getDescription(){
return description;
}


@Override
public IPluginInfo getPluginInfo() {
if(null==pluginInfo){
pluginInfo = new PluginInfo(
"My full name here",
getName(),
"1.0.0",
"AGPLv2",
"My Organisation"
);

((PluginInfo)pluginInfo).setPluginIcon(getUrl());
((PluginInfo)pluginInfo).setPluginColor(Colors.bg_softsmileylemon);

}
return pluginInfo;
}
}

Conclusion

Intamerge is the place where you can build up a palette of all your Java libraries, utilities, and bits of useful code you have written and have a canvas upon where you can wire them into new applications and solutions. Its designed to be very simple to use and adopt and there are tutorials and documentation to help you get up and running. If anything, its fun to use and worth trying.

The new Gartner Critical Capabilities for Full Lifecycle API Management report shows how CA Technologies helps digital leaders with their B2B, open banking, and mobile initiatives. Get your copy from CA Technologies.

Topics:
integration platform ,integration ,workflow designer ,java integration

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}