Results 1 to 8 of 8

Thread: how can I do if I need to do some other jobs after step transaction rollback

  1. #1
    Join Date
    Apr 2008
    Posts
    9

    Question how can I do if I need to do some other jobs after step transaction rollback

    Hello, I have a question to consult every experts. How can I do if I need to do some other jobs after step transaction rollback?

  2. #2
    Join Date
    Dec 2006
    Posts
    1,061

    Default

    Perhaps you could provide some more details as to what you're trying to do after a step rollback. Are you trying to log out some information?

  3. #3
    Join Date
    Apr 2008
    Posts
    9

    Question

    may be I need to mark a flag or trigger other programs to finish the clear jobs.
    Then how can I do?

  4. #4
    Join Date
    Dec 2006
    Posts
    1,061

    Default

    I'm sorry, but I'm still unclear as to what you're trying to accomplish. We really need more details.

  5. #5
    Join Date
    Apr 2008
    Posts
    9

    Question

    Following is my program, I set the commitInterval in the configuration file, and the spring batch framework will commit my data to db automatically. And if the framework roll back , I want to trigger another program in the close method to do some clear jobs. But I don't know how to verify if the transaction is rollback.

    public class DBProcessItemWriter implements ItemWriter, ItemStream, InitializingBean {
    private ProductDao productDao;

    public void write(Object item) throws Exception {
    Product product=new Product();
    product.setProductNumber(item.getProductNum());
    product.setLastUpdateTime(new Date());
    productDao.persist(product);
    }

    public void close(ExecutionContext executionContext) throws ItemStreamException {
    if(transaction commit normally){
    clear the temp data;
    }else{
    trigger another program;
    }

    }
    }

  6. #6
    Join Date
    Jun 2005
    Posts
    4,241

    Default

    You could use a StepExecutionListener (just implement that interface as well). The on error callback gives you the failure case, and the success case is just to move on to the next step.

  7. #7
    Join Date
    Apr 2008
    Posts
    9

    Default

    Sorry, can you give me a sample for this approach?

  8. #8
    Join Date
    Jun 2005
    Posts
    4,241

Posting Permissions

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