-
Aug 25th, 2009, 07:09 AM
#1
Update batch instance before and after batch.
Hi!
I wonder how I'm going to solve this issue;
there's a "third party system" that's going to initiate a batch implemented with Spring Batch.
When the batch starts I want to set a status to the table where the ordered batch is in order to say; "batch is running" ..., and when the batch is finished, I want to set status "batch finished".
I recon I need two steps extra for this; One to set the "batch is running" status, and one to set the "batch finished" status.
These steps need to contain a reader (to read the given record of my "ordered_report" table), and a writer that will set status and write to the database. Commit interval = 1.
Is there any readers that may fit this need, or should I just make a new one?
-
Aug 25th, 2009, 09:05 AM
#2
A) You could do it with a JobExecutionListener very easily. You don't need a reader or a writer, you would just modify the database directly in the beforeJob and afterJob methods.
B) I don't think you really need to do this since the BATCH_JOB_EXECUTION table lists the status already. If I were you I would just look up the status from that table.
-
Aug 25th, 2009, 09:08 AM
#3
Ah.... yeah... thank you.
Always good to get a second opinion of things.
but regarding your "B"; yes; only it's a status that's interresting for the 3'rd party legacy system that got it's own ... batch... thingie..., so It's a requirement. But thanx anyway!
-
Aug 26th, 2009, 06:47 AM
#4
However......... I need the JobExecutionListener to commit after setting the status... Is this something that could be done as well ("out of the box"), or would I have to get the datasource from "somewhere else"?
-
Aug 27th, 2009, 05:11 AM
#5
I injected the datasource and made a new transaction ..., and it works. Thanks!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules