Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

SpringBatch-Passing an Object to Listener from the Processor

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

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!
 
Ranch Hand
Posts: 607
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
http://static.springsource.org/spring-batch/apidocs/org/springframework/batch/item/ExecutionContext.html
Note: This is the correct way, in case you want your job to be re-startable from the point of failure.
 
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic