Friday, May 27, 2011

How to Launch Spring Batch from Quartz in Grails

Here is a quick tip on how to launch Spring Batch from a Quartz job in Grails.  Why would you want to do this?  To periodically run batch jobs in your Grails application.

You will likely want this to be a non-concurrent Quartz job, so that you don't have concurrent batch processing going on.  Other then that, the Quartz job needs the job bean to run, and a job launcher.  Those can be configured in your standard Spring Batch way in the resources.xml file in Grails.

Other notes:
  • TaskExecutor configuration works great, and I would love to see GPars as a mechanism to define task executors for Spring Batch
  • There were no issues using Groovy classes as implementors of ItemReader, ItemProcessor, or ItemWriter in Spring Batch
  • There were no issues having Spring Batch beans, step scoped, injected with Grails managed beans
  • Grails transaction manager did not appear to be picked up by Spring Batch, so I declared a ResourcelessTransactionManager
  • Do not forget to use StepScope, so you can re-use other beans in your Grails configuration directly in your configured jobs, simply delcare with: 
<bean class="org.springframework.batch.core.scope.StepScope" />


  1. excellent post and blog in general

  2. Bài post của admin hoàng hảo, thank bạn đã share.
    Xem tại Trang mạng : Giá đá thạch anh

  3. Kiến thức của tác giả rất hay, cám ơn bạn đã chia sẻ.
    Page hữu ích : Bán đá thạch anh vụn

  4. Bài post của tác giả cũng hay, thank bạn đã share.
    Xem tại website : Gia công đá thạch anh

  5. Mục post của anh khá được, anh đã chia sẻ.
    Xem thêm tại website: Vòng tay đá thạch anh

  6. Bài viết của tác giả quá hữu ích, cám ơn bạn đã share.
    Xem tại website : Thiềm thừ