Announcement Announcement Module
Collapse
No announcement yet.
how can I do if I need to do some other jobs after step transaction rollback Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

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

    Comment


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

      Comment


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

        Comment


        • #5
          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;
          }

          }
          }

          Comment


          • #6
            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.

            Comment


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

              Comment


              • #8
                http://static.springframework.org/sp...n.html#d0e4202

                Comment

                Working...
                X