Results 1 to 3 of 3

Thread: retryable chunk

  1. #1
    Join Date
    May 2011
    Posts
    2

    Question 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 at 05:00 PM.

  2. #2

    Default

    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?

  3. #3
    Join Date
    May 2011
    Posts
    2

    Default

    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 at 09:13 AM.

Posting Permissions

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