Reputation: 1
Good day. I could not find an answer for this from google or from the search in stackoverflow, so please be patient if I missed a post for it.
I need to run a Spring Batch (v3.x) using CommandLineJobRunner because we need to submit run parameters, including a flag to process all codes, or process a subset of codes.
I'm thinking we might use a parameter listing the codes (if the process_all flag is set to 'N'). The params might look like this:
-Dexec.args="birthdayBatchConfig.xml birthdayBatchJob process_all=Y run_date=022017" I plan to take the run day from the day of the run)
I would then add the subset of codes to process like: code_list=[22 34 56 73 82 84 86 87} ...I would then get the code_list param and parse out the codes with a Tokenizer. I'm doing some experimenting to see if this might work, but if someone has had to do this before, any advice would be helpful. Thank you.
Upvotes: 0
Views: 616
Reputation: 2658
I'm thinking a simple way as this
@Value("#{jobParameters['codes']}") private String[] codes;
Spring will handle the split with commas separator for us behind the scene.
Let me know if you have more question
Upvotes: 1