Admin project contains classes to implement features including remote chunking and partitioning as
well as other integration patterns that are still in development. Although Spring Batch Integration is
currently a subproject of the Spring Batch Admin project, the long-term intent is to break it out once the
community has grown enough.
To implement remote chunking in your jobs, you use the helper project contained in Spring Batch
Admin called Spring Batch Integration. This project is still young and growing in the community. Once
it's mature enough, it will be branched into its own independent project. Until then, it has a number of
helpful resources for your scalability needs.
To configure a job using remote chunking, you begin with a normally configured job that contains a
step that you want to execute remotely. Spring Batch allows you to add this functionality with no
changes to the configuration of the job itself. Instead, you hijack the ItemProcessor of the step to be
remotely processed and insert an instance of a ChunkHandler implementation (provided by Spring
Batch Integration). The org.springframework.batch.integration.chunk.ChunkHandler interface has a
single method, handleChunk , that works just like the ItemProcessor interface. However, instead of
actually doing the work for a given item, the ChunkHandler implementation sends the item to be
processed remotely and listens for the response. When the item returns, it's written normally by the local
ItemWriter. Figure 11-16 shows the structure of a step that is using remote chunking.
Step using remote chunking
Figure 11-16. The structure of a step using remote chunking
As Figure 11-16 shows, any one of the steps in a job can be configured to do its processing via
remote chunking. When you configure a given step, that step's ItemProcessor is replaced with a
ChunkHandler, as mentioned previously. That ChunkHandler's implementation uses a special writer
( org.springframework.batch.integration.chunk.ChunkMessageChannelItemWriter ) to write the items to
the queue. The slaves are nothing more than message-driven POJOs that execute your business logic.
When the processing is completed, the output of the ItemProcessor is sent back to the ChunkHandler
and passed on to the real ItemWriter.
For this example, you update a table of customer information with the longitude and latitude of the
address each customer has on file. These coordinates are useful for using most mapping APIs on the
Web to display a marker for a given point. To do obtain the geocoding for your customers, you call a web
service, sending it the address information and receiving the customer's longitude and latitude to be
The potential for a bottleneck exists when you call to a web service you don't control, so you use
remote chunking to process this step. To begin, let's make a list of the items you need to address in this