File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Spring and the fly likes Spring Integration and Spring Batch Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Spring Integration and Spring Batch" Watch "Spring Integration and Spring Batch" New topic

Spring Integration and Spring Batch

jianming chen
Ranch Hand

Joined: Jul 21, 2009
Posts: 33
I used Spring integration in a lot of cases and really liked it. And I found it is also very handy to create cron integration jobs by using polling channel.
But in the case like I have huge files to process nightly, I can use Spring integration to do the work, but Spring Batch looks like more appropriate for the work.
so what is the best argument to make choice?
Mark Spritzler

Joined: Feb 05, 2001
Posts: 17276

There doesn't have to be a choice. As a matter of fact a huge amount of Spring Batch Jobs also uses Spring Integration. Because many times the processing requires talking to many systems and Spring Integration really helps out there.

Sometimes Spring Integration can be used to fire off a Batch job. For instance, wouldn't it be cool that if a Batch job fails you receive a tweet on twitter that you can reply back to to fire a rerun of the job?


Perfect World Programming, LLC - iOS Apps
How to Ask Questions the Smart Way FAQ
Gunnar Hillert
Spring Integration Committer

Joined: Oct 31, 2012
Posts: 5

Take a look at chapter 16 of "Spring Integration in Action": "Integrating Spring Batch and Spring Integration". It provides a very good overview of how to integrate Spring Batch and Spring Integration:

* Launching batch jobs through messages
* Providing feedback with informational messages (via StepListener, ChunkListener, JobExecutionListener)
* Externalize batch process execution (Call Spring Integration from inside batch jobs)

We talked a little bit about those options in our recent (2012) SpringOne talk:
There will also be an audio/video recording of that presentation available in the upcoming weeks/months.

As Spring Integration and Spring Batch are under the same umbrella of Spring projects, you will see an increasingly tighter integration between Spring Batch and Spring Integration. As for your specific situation, take a look at the features provided by Spring Batch. I believe one could make an argument that for simple use-cases with small batch files, you can do the job efficiently using Spring Integration only (Use the simple/more generic tool first). However, if you start dealing with massive files that don't easily fit into memory anymore, take a very long time to process, and you start feeling the pain, then you probably need to seriously consider Spring Batch. Other people may have a different view point but I hope this provides you with some useful guidance.



Disclaimer: I am a Spring Integration committer
Saifuddin Merchant
Ranch Hand

Joined: Feb 08, 2009
Posts: 607

I'd say Spring Batch would fit the bill when you need to do BATCH processing - Batch frameworks have a shared vocabulary & need. Batch provides features like re-startability, chuck-commit, multi-threading support out of the box.
Spring Batch also offers a lot of the shelf Reader and Writer components - that make writing batch jobs more standard and easy.

If you are looking for these features for a "Job" why re-invent the wheel - use Spring Batch.

Cheers - Sam.
Twisters - The new age Java Quiz || My Blog
I agree. Here's the link:
subject: Spring Integration and Spring Batch
It's not a secret anymore!