Announcement Announcement Module
No announcement yet.
Update batch instance before and after batch. Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Update batch instance before and after batch.


    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
    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
      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
        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
          I injected the datasource and made a new transaction ..., and it works. Thanks!