INFO : com.apress.prospring3.ch20.batch.listener.ImportContactJobListener - Contact: Contact -
Id: 3, First name: Kim Fung, Last name: Ho, Birthday: 1980-07-30T00:00:00.000+08:00
INFO : org.springframework.batch.core.launch.support.SimpleJobLauncher - Job: [FlowJob:
[name=importContactsJob]] completed with the following parameters:
[{inputFile=C:/temp/contacts.xml}] and the following status: [COMPLETED]
Contact import job completed successfully
The testing data file (in test-data.sql) contains two contact records, and from the output, you can
see that the contact (with id = 3) in the XML file was imported successfully.
Spring Batch provides a solid foundation that can help fulfill complex batch job requirements. For
more details, we recommend the book Pro Spring Batch (Apress, 2011).
Using Spring Batch with Spring Integration
While Spring Batch provides a sophisticated batch job execution environment, Spring Integration
provides an excellent integration environment for enterprise applications. With Spring Integration,
information exchange with external systems becomes much easier, no matter where the information
comes from or needs to be sent to. Out-of-the-box support for file, e-mail, and JMS-based integration is
provided.
Even if your initial batch job execution requirements are very simple, we still recommend that you
set up Spring Batch to integrate with Spring Integration to ensure that the application execution
environment is flexible enough to cater to more complicated integration requirements in the future.
In the following sections, we will demonstrate how Spring Batch can work with Spring Integration to
implement a file polling mechanism so that when a file arrives in a folder, Spring Integration will launch
the import contact job automatically.
Introducing Spring Integration
Some core concepts of Spring Integration are as follows:
Channel: Spring Integration is a message-based integration framework, and a
·
channel is the placeholder for messages. Channels are the glue for linking up the
various message producers and consumers within an application.
Message endpoint: In Spring Integration, message endpoint comes in the form of
·
adapters, which connect application components to various channels. In the
import contact job, we will use the <inbound-channel-adapter> tag to connect the
file polling component to the batch job request channel.
Transformer: As the name implies, a transformer connects different channels and
·
performs the necessary message transformation.
Service activator: In Spring Integration, the service activator is an endpoint that
·
invokes the business process of an application by passing in the appropriate
message.
Figure 20-6 provides a graphical view of how the components in Spring Integration and Spring
Batch work together to launch the import contact job by using a file polling mechanism.
Search WWH :
Custom Search
Previous Page
Spring Framework 3 Topic Index
Next Page
Spring Framework 3 Bookmarks
Home