Announcement Announcement Module
Collapse
No announcement yet.
retryable chunk Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • retryable chunk

    Hi all,
    I started using spring and spring batch a couple months ago and to be honest I love it although some times it makes me crazy but it's ok I'm learning .

    Now I'm having a problem which I don't know how to solve.
    In order to make my process robust for example if sql connection fail, I'm trying to configure the chunk processing with retry option.
    HTML Code:
          <batch:step id="procesa" next="fin" >
                <batch:tasklet  task-executor="taskExecutor" throttle-limit="15" transaction-manager="transactionManager" >
                    <batch:chunk
    					reader="aparatoReader"
    					processor="aparatoProcess"
                                            writer="aparatoWriter"
                                            commit-interval="5"
                                            retry-limit="2"
                        >
                        <batch:retryable-exception-classes>
                            <batch:include class=""/>
                        </batch:retryable-exception-classes>
                    </batch:chunk>
    
                    <batch:no-rollback-exception-classes>
                        <batch:include class=""/>
                    </batch:no-rollback-exception-classes>
    
                    <batch:listeners>
                        <batch:listener ref="taskListener"/>
                    </batch:listeners>
                </batch:tasklet>
            </batch:step>
    The problem is once I compile and launch with the retry configuration, the process fail at the beginning when Spring is initializing beans throwing the following exception:

    "Exception in thread "main" org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'finanzas': Cannot create inner bean '(inner bean)' of type [org.springframework.batch.core.configuration.xml.S impleFlowFactoryBean] while setting bean property 'flow'; nested exception [....]"

    My ItemWriter is really basic it just launch mybatis query through a dao....

    Without retry the process works....

    I followed chapter 5.1.6 of the user guide: http://static.springsource.org/sprin...igureStep.html

    What I'm missing
    Thanks
    Last edited by lobor7; May 14th, 2011, 05:00 PM.

  • #2
    How about providing a class? An empty class seems very weird to me. If you want everything, use java.lang.Exception. That being said, the no rollback config seems weird as well. What are you trying to do exactly?

    Comment


    • #3
      Yes! the problem was 'no-rollback with empty class' until now I've been working with that but since the moment I put retryable config it stopped working so I just delete no-rollback and it works!

      what I want to achieve is If a database server fall down, restart or something like that my process retry sql query until the server goes online again.

      What I'm seein weird now is altough I wrote this:
      Code:
              <batch:step id="procesa" next="fin" >
                  <batch:tasklet  task-executor="taskExecutor" transaction-manager="transactionManager" >
                      <batch:chunk reader="aparatoReader" processor="aparatoProcess" 
                                   writer="aparatoWriter" commit-interval="5"
                                     retry-limit="200"
                          >
                          <batch:retryable-exception-classes>
                              <batch:include class="java.sql.SQLException"/>
                          </batch:retryable-exception-classes>
                      </batch:chunk>
                      <batch:listeners>
                          <batch:listener ref="taskListener"/>
                      </batch:listeners>
                  </batch:tasklet>
              </batch:step>
      And in my itemReader something like this:

      trials++;
      if (trials < 2 ) {
      throw new SQLException("Connection failed");
      } else {
      doread....
      }

      The process first throw the exception but second time success doing read, process and write. However it doesn't continue with the next step of the job and the listener show me this:

      15/05/2011 13:43:30 INFO Job: [FlowJob: [name=finanzas]] completed with the following parameters: [{}] and the following status: [FAILED]

      Say failed when it should be a success.
      Last edited by lobor7; May 15th, 2011, 09:13 AM.

      Comment

      Working...
      X