Results 1 to 4 of 4

Thread: Converting old job

Hybrid View

  1. #1
    Join Date
    Jul 2007
    Posts
    15

    Default Converting old job

    Hi, I'm trying to convert some old jobs to use Spring Batch. Unfortunately the old jobs are somewhat monolithic and are quite tightly coupled, so pulling the pieces out to fit into the read-write pattern has been tricky.

    The job flow is like this:

    1)Update Header record status to in process
    2)Read detail records
    3)Process/Write detail records
    4)Update Header and send email noting results (this requires using counters accumulated in the previous phase)

    The issue is with line 1 and 4. Where does that logic belong? Reader? Writer? BeforeStep/AfterStep? Somewhere else? It's not really after or before the step, it's part of the step, it's just after the reads/writes are done.

    Thanks for any help/advice.

  2. #2
    Join Date
    Sep 2008
    Location
    Chicagoland, IL
    Posts
    338

    Default

    Is this the processing of a flat file? If so, do you actually update the header record in the file or generate a new file with a new header record?
    Michael Minella
    Spring Batch Lead
    Author - Pro Spring Batch
    http://www.michaelminella.com
    Twitter: @MichaelMinella

  3. #3
    Join Date
    Jul 2007
    Posts
    15

    Default

    Actually it's processing a database "header" record, as we call it from the db and does update that record. The header record is like a parent record of summary information of a process, after which actual detail db records get processed.

    Thanks again for you help.

  4. #4
    Join Date
    Sep 2008
    Location
    Chicagoland, IL
    Posts
    338

    Default

    Ah. That makes life much easier. In that case, I would recommend an StepExecutionListener (assuming 1-4 are all executed within a single step). You can update the header record in the StepExecutionListener#beforeStep method and again in the StepExecutionListener#afterStep.

    With regards to number 4 specifically, I would actually break that up into two things. First do all your processing (1-3 and the update of the header record in 4). I would then use a second step to send the emails. This allows you to consider the processing of the records as complete (and not need to rerun that logic) even if the sending of the email fails.
    Michael Minella
    Spring Batch Lead
    Author - Pro Spring Batch
    http://www.michaelminella.com
    Twitter: @MichaelMinella

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •