Results 1 to 1 of 1

Thread: Abandoned

  1. #1
    Join Date
    Apr 2007
    Posts
    5

    Post Abandoned

    I have a simlar problem to the one sidetracked to at the end of this thread

    I have a job that will process items, and when a certain business exception occurs I skip those and mark them for later processing. This is carried out in a subsequent step.

    The problem arises when a 'hard failure' occurs (I.e when an item is impossible to process due to a formatting error) . This step then fails, but (as Dave points out in the thread) since the 'cleanup' step that runs subsequently the FAILED step is marked as ABANDONED. Therefore the step can not be restarted. (using Spring batch 2.0.3, I cant see anything changing this fact in 2.1, but I might be wrong...)

    I am trying to force a status of FAILED back onto that step, but that is not reflected in the DB afterwards.


    The Code that is attempting a force

    Code:
    for (StepExecution execution : stepExecution.getJobExecution().getStepExecutions()) {
                if(execution.getStepName().equals(PROCESSING_STEP) && execution.getStatus().equals(BatchStatus.ABANDONED)){
                    execution.upgradeStatus(BatchStatus.FAILED); // setStatus(BatchStatus.FAILED)
                }
            }

    Now i suspect that at this time the damage is already done, the stepExecution status is written to the DB and will not be updated.
    It does not work in the step that fails either, as the exit status at that point is FAILED.

    Modifying the DB value itself works, but I would rather not code that into the process, it feels like a pretty dirty hack...


    UPDATE

    With the following addition the DB status is updated..
    Code:
                jobRepo.update(execution);
    But the relies on injecting the jobRepository!!

    /UPDATE
    Appreciate any suggestions....

    regards

    Johan
    Last edited by jelmstrom; Jun 11th, 2010 at 07:50 AM. Reason: hacked a workaround

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
  •