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.

Add Custom Meta Data to a Spring Batch job

Sep 7th, 2011, 01:59 PM

How do I add custom meta data to a Spring Batch job? We are currently using Spring batch to kick off jobs from our web app. I want to be able to store the user who kicked off the job along w/ the timestamp and retrieve that once I query the job repo. I'm using HibernateCursorItemReader as my reader and implemented ItemWriter to persist to the database.
This is my job

into your reader/writer? The given service should provide you with a user name taken from your application internals.

In general case we can't guess what is "user" in your application, how it is provided to your application and how it is managed. If you want to access user given by HTTP request, then you can use (one need to populate the current HTTP request to thread either by using org.springframework.web.servlet.DispatcherServlet or org.springframework.web.context.request.RequestCon textListener or org.springframework.web.filter.RequestContextFilte r):