Java Reference
In-Depth Information
St. Louis, NY
Spring Batch provides the ability to reuse just about any existing Spring service you've created as an
ItemWriter, with good reason. The code your enterprise has is battle tested in production, and reusing it
is less likely to introduce new bugs and also speeds up development time. The next section looks at using
JMS resources as the destination of items processed within a step.
Java Messaging Service (JMS) is a message-oriented method of communicating between two or more
endpoints. By using either point-to-point communication (a JMS queue) or a publish-subscribe model
(JMS topic), Java applications can communicate with any other technology that can interface with the
messaging implementation. This section looks at how you can put messages on a JMS queue using
Spring Batch's JmsItemWriter .
Spring has made great progress in simplifying a number of common Java concepts. JDBC and
integration with the various ORM frameworks come to mind as examples. But Spring's work in
simplifying interfacing with JMS resources is just as impressive. In order to work with JMS, you need to
use a JMS broker. This example uses Apache's ActiveMQ.
Apache ActiveMQ is one of the most popular and powerful open source JMS implementations
available. It has the ability to interface with a number of different languages (Java, C, C++, C#, Ruby, and
so on), provides a full JMS 1.1 implementation, and yet still is one of the easier message brokers to work
Before you can work with ActiveMQ, you need to add its dependencies and Spring's JMS
dependencies to the POM so that it's available. This example works with ActiveMQ version 5.4.2, which
is the most current version as of this writing. Listing 9-47 shows the dependencies you need to add to the
Listing 9-47. Dependencies for ActiveMQ and Spring JMS
Now you can begin to put ActiveMQ to work. Before you get into the code, however, let's look at the
processing for this job because it's slightly different than before.
Search WWH ::

Custom Search