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" />

5 comments:

  1. excellent post and blog in general

    ReplyDelete
  2. 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

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

    ReplyDelete
  4. 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ừ

    ReplyDelete
  5. I have read your blog its very attractive and impressive. I like it your blog.

    Spring online training Spring online training Spring Hibernate online training Spring Hibernate online training Java online training

    spring training in chennai spring hibernate training in chennai

    ReplyDelete