Results 1 to 5 of 5

Thread: Update batch instance before and after batch.

  1. #1
    Join Date
    Jul 2009
    Posts
    15

    Default 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?

  2. #2
    Join Date
    Feb 2008
    Posts
    488

    Default

    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.

  3. #3
    Join Date
    Jul 2009
    Posts
    15

    Default

    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!

  4. #4
    Join Date
    Jul 2009
    Posts
    15

    Default

    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"?

  5. #5
    Join Date
    Jul 2009
    Posts
    15

    Default

    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
  •