This forum is now a read-only archive. All commenting, posting, registration services have been turned off. Those needing community support and/or wanting to ask questions should refer to the Tag/Forum map, and to http://spring.io/questions for a curated list of stackoverflow tags that Pivotal engineers, and the community, monitor.

Did you mean to say that you want to launch a Spring Batch job from an MDB? If so I suggest you look at the quartz and JMX samples (the latter is called TaskExecutorLauncher) for some code that you could use in your listener. Does that make sense (your post is pretty thin on details)?

I am also working on some message-driven use cases with Spring Integration -not quite ready for public use yet (Spring Integration is only at m3), and those implementations are directly usable with JMS, by virtue of the JMS features of that project.

Comment

Here is my use case in detail so that you get a clear insight. We are working on the claim processing system. There are spring batch steps which reads the claims.txt file and store a data into the database and push as message in the message queues called claim queue. There is ClaimProcessingMDB attached to the claim queue, which picks message and perform the claim processing, which are also composed of spring batch steps

Now what I want to achieve is seamless integration of spring batch with ClaimProcessingMDB (which extends AbstractJmsMessageDrivenBean) so that it passes the message received in onMessage method to claim processing steps.

What you have is a Job with a Step that has processing split over multiple processes connected by JMS. In that case you need to get the message back from the processing thread to the dispatcher to say that it succeeded or failed. If you can't do that asynchronously there is no benefit at all to splitting the processing. But if it is asynchronous you also need some special logic in the dispatcher to accept the responses and make sure that failures are detected and all the statistics for the job as a whole are accurate.

These problems are not difficult to overcome, but currently you will have to do some work in the dispatcher and the processor. I am working on a simliar use case with Spring Integration,and when the features of Spring Integration catch up to what we need here that will probably appear as a sub-project in Spring Batch (we haven't decided exactly yet).

Comment

You can stuff it in the ExecutionContext. I'm not sure how that helps you though. If you have an object to be processed it is not naturally an input to a Step, rather it is an item, which is processed by an ItemWriter. Couldn't you re-engineer your job to make this object an item?