|
|
How to pass arguments from one jobExecution to the next?
I wonder how I can pass job arguments from one jobExecution to the next one. I want to create thouse arguments inside the jobProcessor.
An example:
I have different forum entries from user A and user B. Now I want to run a batch job that copies all new entries to another db table. After that I want to save the dates of the last forum entry of user A and B for the next job execution. So the next time I will run the job I can use this date information.
I first thought I can use the jobParameter but I figured that this is only used for job identification. I could also add a column to the user table to save this information but that would be a dirty work around. Is there a possibility to save custom information for the next jobExecution?
Thanks, Peter
Spring Batch has the ItemStream interface and saves the ExecutionContext instances in its repository with the Step- and JobExecutions. As long as you don't store massive amounts of data, that should be fine as a dump for business data, but since it is there mainly to support automatic restart (same job instance), you would have to manage the transfer from one job instance to the next.
The other framework feature that is relevant is JobParametersIncrementer. That only makes sense if you know the values of the parameters before you start the job (obviously), but I suppose an incrementer implementation could look in the JobRepository (or in a user-defined database table). |
|