Spring Integration 1.0.3 Samples: just add Maven

Engineering | Mark Fisher | July 21, 2009 | ...

Spring Integration 1.0.3 is now available. You can find links to the download, reference manual, and more at the Spring Integration home. This release includes quite a few changes, but in this blog, I'm going to focus on one in particular. Starting with this version, the samples are fully self-contained and Maven-enabled. That means you can download the distribution, go into the 'samples' directory, run 'mvn install' and then import the projects into a Maven-aware Eclipse instance, such as the SpringSource Tool Suite. Here's the step-by-step breakdown...

Installing and Running the Samples

  1. Make sure you have Maven installed and in your path (2.0.9 or later is required). If not, download it and follow the setup instructions: http://maven.apache.org
  2. If you don't already have a Maven-aware version of Eclipse, you can download the SpringSource Tool Suite (STS) which will support these projects out-of-the-box (STS even includes support for the OSGi-enabled samples). Alternatively, you can manually add a Maven plugin, such as m2eclipse to an existing Eclipse installation.
  3. Download the Spring Integration Samples and unzip.
  4. Within the unzipped "samples" directory, run 'mvn install'. You should eventually see output similar to the following: si-samples-mvn-install-output
  5. Once STS/Eclipse is up and running, choose 'File -> Import...' and within the Wizard choose 'General -> Existing Projects into Workspace'. Then browse to the unzipped 'samples' directory, and you will see all of the projects selected by default: si-samples-import-project-list Either accept all or choose the individual sample(s) that you want to import, and after a few moments of workspace building, you should be ready to run.*

*NOTE: if you import the 'osgi-inbound' project, you will see some errors on that particular project (but you should not see any errors on the other projects after the workspace build completes). Those errors would be resolved after configuring the runtime and the bundle repository. If you would like to work through the OSGi samples, refer to the dedicated chapter in the Reference Manual. Also, we will be posting a blog that goes into detail on those projects within a few days.

Each of the samples has a main method within a "Demo" class (except for 'osgi-inbound' and 'osgi-outbound' which are meant to be deployed within an OSGi environment - to be covered in that upcoming blog post). For example, the 'helloworld' project has 'HelloWorldDemo'. In the javadoc of each demo class, you will find a brief overview of features showcased in that individual sample.

Enterprise Integration Patterns

For those familiar with Enterprise Integration Patterns, here is an overview of some of the patterns that are represented in each sample*:

Pattern / Sample Event Driven Consumer Polling Consumer Message Filter Message Translator Content Based Router Splitter Aggregator Channel Adapter Messaging Gateway Service Activator Request/Reply
cafe X X X X X X X X
filecopy X X X X
errorhandling X X X X
helloworld X X
jms X X X X X
oddeven X X X X X
quote X X X
ws X X X X
xml X X X X X X

*NOTE: All of the samples feature certain common patterns that are essential to the underlying Spring Integration core:

  • Message: Spring Integration Messages encapsulate a POJO payload and a header Map (Reference).
  • Message Channel: Spring Integration includes many Message Channel options for both point-to-point and publish-subscribe. Some include queues for buffering while others dispatch directly to subscribers (Reference).
  • Message Endpoint: At a high level, this includes all components that connect to channels for input and/or output.
  • Messaging Mapper: Spring Integration binds inbound Messages to method arguments and method return values to Message payloads and/or headers.
  • Message Dispatcher: In Spring Integration, channels that do not have a queue use Message Dispatchers to invoke their subscribers.
  • Pipes and Filters: This is the most general pattern describing Message-processing components connected in a loosely-coupled way via channels.
  • Message Bus: Spring Integration essentially turns a Spring ApplicationContext into a lightweight Message Bus within which all of these other components are hosted.

Next Steps

For more detailed information, check out the Samples chapter of the Reference Manual and the README file located directly in the "samples" directory of the main distribution. Also, stay tuned for another blog covering the new OSGi based samples added in Spring Integration 1.0.3. That should be posted within a few days.

Last but not least, be sure to check out the "POJO Messaging" sample from the Spring BlazeDS project (see the build and run instructions in the Spring BlazeDS Reference Manual). That demonstrates Flex Producer and Consumer elements whose "destinations" are backed by Spring Integration Message Channels.

Get the Spring newsletter

Thank you!

Get ahead

VMware offers training and certification to turbo-charge your progress.

Learn more

Get support

Spring Runtime offers support and binaries for OpenJDK™, Spring, and Apache Tomcat® in one simple subscription.

Learn more

Upcoming events

Check out all the upcoming events in the Spring community.

View all