Taking A Camel-First Approach to Integration
August 11, 2021 Alex Woodie
Unicorns and Chupacabras may not exist on this planet, but camels certainly do. And according to midrange open source guru Jesse Gorzinski, IBM i shops would do well to take a camel-first approach to integration challenges.
The camel, of course, is Apache Camel, the Java-based integration framework that’s designed to connect two or more systems. During the recent OCEAN TechCon21 conference, Gorzinski, IBM’s business development manager for open source on IBM i, presented a compelling overview of Camel and how it can benefit administrators and developers in an IBM i environment.
“Apache Camel can make it pretty easy to tie really anything to anything,” Gorzinski said during his OCEAN session, which is titled Integrate IBM i with Anything using Apache Camel. “If you’re doing any kind of active integration activity, [if] you’re tying multiple technologies together, Camel can come in really handy.”
At a high level, Camel is message-oriented middleware, not unlike the enterprise service busses (ESBs) that were popular in the IT world at one point. Camel employs a rule-based routing engine that gives the user a certain degree of control over how and when messages and data are sent.
“Camel is this integration layer that helps you define things in the terms of messages and inputs and outputs for those messages,” Gorzinski explained. “With Camel, you have this notion of a processor or an endpoint. It simply takes a message in, does something with it, and then sends that message somewhere else.”
By using Camel, IBM i shops can leverage a lot of integration work that has already been done by the open source community. That includes the integration with jt400, which provides Camel with connectivity to IBM i technologies, including the database, CL, and message logs, like the QSYSOPR queue. It also includes the array of connectors that have already been built, such as for Apache Kafka, IoT devices, and more.
One of the core concepts in Camel is the idea of a route. A route defines the starting point and the endpoint for the data flow. Once the route (with one or more end points) has been defined, it can be automatically executed by Camel.
The list of endpoints that Camel can work with is huge, Gorzinski says. “I can’t fit them all on a screen,” he said. “There’s components in there for doing interaction with FTP sites and IRC chat. There’s components in there for talking to MongoDB, talking to Twitter and Slack and SFTP. There’s components for doing database queries and running commands and interacting with Amazon AWS type of stuff.” Blockchain. EDI. Watson. You name it, Camel’s got it.
“One of the things that those components can do is interact with IBM i, because there is a component called jt400,” Gorzinski says. “And if you’ve done any kind of Java programming with IBM i or its predecessors, you know that jt400 is one of the names, one of the several names, for the IBM Toolbox for Java, which lets you interact with IBM i from Java code.”
“If you forget everything else I say today just remember this,” Gorzinski continued. “The key takeaway is that any one of those components can be integrated with any other of those components that Apache Camel has, which means in the IBM i case, you can now integrate IBM i with anything else that there’s a component for.”
Camel makes it easy, because you don’t have to actually write code. In fact, Gorzinski called Camel a “low-code” solution for integration. You can write code if you like. The two most common ways to write code are the domain specific languages for Java on the one hand, and Spring and Spring Boot on the other. But the amount of code you have to write to get stuff done with Camel is quite low.
“You don’t have to write 30 lines of code to send a message, for instance,” said Gorzinski, who called Camel the “Swiss Army knife” of integration tools in a 2020 IT Jungle interview. “Apache Camel has these integration points through jt400 that let you interact with data queues, message queues, or even direct program invocation, and so you can call an RPG program or CL program directly with Apache Camel as well.”
Gorzinski covered core Camel concepts in his 45-minute session. Routes are defined by starting points and endpoints, and those starting and endpoints are defined with uniform resource indicators (URIs). Like uniform resource locator (URLs), URIs provide a pathway to a certain resource, such as a SMTP server or the QSYSOPR queue.
Another core concept in Camel is the idea of an enterprise integration pattern (EIP). “These are just patterns that are seen throughout any kind of enterprise integration activity,” Gorzinski says. “So they just formalize the type of coding patterns and ways to attack problems into this this notion of integration patterns or enterprise integration patterns.”
There are several popular EIPs in the Camel world, and Gorzinski covered several of them. For starters, one type of EIP is a content-based router, which essentially defines the flow of events that will happen when triggered by an event, such as which department to send a new order when a new order hits the queue. Another type of EIP is a content enricher, which adds additional information to a message, such as a language translation from English to Spanish.
Gorzinski provided several practical examples of how an IBM i professional can use Camel. For instance, say an IBM i administrator wants to receive an email every time disk capacity on a Power System server exceeds a certain number. Using the URIs and EIPs, the administrator can define his Camel route to generate and send an email when the disk capacity limit is exceeded.
“And unlike the default system messages, it tells you how full the disks are,” Gorzinski added. “There might be a big difference between 91% full and 99% full.”
There are several ways you can use Camel, including IDEs that abstract away some of the complexity. Gorzinski recommends that beginners avoid using those IDEs until they get at least a basic understanding of what’s going on under the covers with Camel.
Two tools that Gorzinski recommended for use with Camel are Maven and Chameleon. Maven is a build automation tool, primarily used for Java, while Chameleon is a recently released tool that automates some of the component selection process for users and builds a skeleton project, so all the user has to do is plug in the logic behind the routes you define, he says.
“There’s a lot you can do a lot you can do with Camel,” Gorzinski said. “Typically, whenever I hear somebody taking on some kind of integration type activity and turning to open source — first off, that’s a really good mindset, because open source has all of these connectors for tons of technologies.”
“But sometimes I like to [take] what I call a Camel-first approach, and say can this be done with Camel?” he continued. “And if the answer is yes, then try doing it with Camel first because you might find that it might only be a few lines, it might be three lines, five lines, two lines of Apache Camel code, route definitions, and you’re done.”