Spring Integration With JMS

Ryan McCullough Architecture, Development Technologies, Java, Programming, Spring, Tutorial Leave a Comment

Attention: The following article was published over 7 years ago, and the information provided may be aged or outdated. Please keep that in mind as you read the post.

What is Spring Integration?

The popular definition (via Google), JavaWorld.com says: “Spring Integration is an enterprise integration framework that provides out-of-the-box implementation of the patterns in the now-classic Enterprise Integration Patterns…

Spring.io defines it as: “Spring Integration enables lightweight messaging within Spring-based applications and supports integration with external systems via declarative adapters

If you are a Spring Integration pro, this article may not be for you, as I’m still relatively new to the material myself.  This is only intended to be an elementary example of the simplest form with regards to Spring Integration and JMS queues.

Regardless of all that pre-posturing, perhaps you may find some articulations that can help you to bridge the gap in your development effort!

An Example

After some flailing about and trying to attach meaning to the flood of terminology, I came to the following conclusion: In my very limited (JMS-based) world, the most basic example I needed was reduced to 3 pieces, connected in the following way:  Adapter –> Channel –> Service

In a sense, Spring Integration is much like sending a child to school…

spring integration

The Adapter resembles the parent, getting the child ready for school; A lot of tedious preparation work to prepare for the journey ahead. (For the sake of simplicity, I’ve tried to keep this example is very concise, but do not be surprised to see your configurations significantly inflate.)

For my project, that meant implementing a HeaderMapper for the Message Driven Channel Adapter, so that I could retain the original JMS queue name (called the JMSDestination) in the MessageHeaders for use later in the Service Adapter.

The channel, resembling the school bus, is mostly just a transport pipe, offering very few options, seemingly intended to decouple the different endpoints from one another. (It still breaks my heart every time I see them off to school! #sniff)

The Service Activator is the journeys (potential) end with Spring Integration, and begins with the actual business requirements of your project.

Hopefully, this was an easy to follow, and light example of Spring Integration, and you are now or soon to be, up and running in a Spring Integration test or better!

Sample XML

Below is a sample of XML you might find useful for getting set up with your first application:

(Click the graphic for a link to the source!)

— Ryan McCullough, [email protected]

0 0 votes
Article Rating
Notify of
Inline Feedbacks
View all comments