jQuery in Action, 3rd edition
The moose likes Spring and the fly likes SpringBatch-Passing an Object to Listener from the Processor Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "SpringBatch-Passing an Object to Listener from the Processor" Watch "SpringBatch-Passing an Object to Listener from the Processor" New topic

SpringBatch-Passing an Object to Listener from the Processor

Konda Golamaru
Ranch Hand

Joined: Dec 12, 2005
Posts: 36

I have the requirement where I need to construct a Map with all incoming entities into the processor. When the processing is done, I need to make the Map available to Listener where I need to look into each object in the map and remove the objects which are not required after further processing.

My question is: How to make the Map which is constructed in the processor be available to Listener. Is there any alternative approach(other than listener)? I am looking for a kind of delegator where I can hand over the map(which is constructed in the processor) to delegator so that I can do the final processing in the delegator e.g. updating to db or creating error report etc.

Thanks and any suggestions are welcome!
Saifuddin Merchant
Ranch Hand

Joined: Feb 08, 2009
Posts: 607

There a quite a few ways in which you could pass the map to the listener.

a) have the processor itself implement the listener (StepExecutionListener with @AfterJob)
Then do the end processing here or pass the map to a DelegateObject that will do the processing.

b) have the map created by spring (in the spring config)
Then you an create any listener and have this map passed to it

c) Save the map in the StepExecutionContext. Then it can be retrieved in the listener
Note: This is the correct way, in case you want your job to be re-startable from the point of failure.

Cheers - Sam.
Twisters - The new age Java Quiz || My Blog
I agree. Here's the link: http://aspose.com/file-tools
subject: SpringBatch-Passing an Object to Listener from the Processor
It's not a secret anymore!