Results 1 to 10 of 10

Thread: RowMapper is repeating for the same row in RuntimeException

  1. #1

    Default RowMapper is repeating for the same row in RuntimeException

    Hi all, i got a quesiton here

    i am using spring batch 1.1.2. This is my step configuration

    PHP Code:
    <bean id="helloStep"
            
    class="org.springframework.batch.core.step.item.SkipLimitStepFactoryBean">
            <
    property name="transactionManager" ref="transactionManager" />
            <
    property name="jobRepository" ref="dbJobRepository" />
            <
    property name="itemReader" ref="validatingItemReader" />
            <
    property name="itemWriter" ref="fileItemWriter" />
            <
    property name="commitInterval" value="2147483647" />
            <
    property name="streams" ref="itemReader" />
            <
    property name="skipLimit" value="2147483647" />    
            <
    property name="skippableExceptionClasses" value="org.springframework.batch.item.validator.ValidationException"/>
        </
    bean


    And this is my mapper
    PHP Code:
    public Object mapRow(ResultSet rsint rowNumthrows SQLException {
            
    System.out.println("mapping " rowNum);
            throw new 
    NullPointerException();
            
    //return str;
        


    Basically when i execute this, the step seems to retry the MapRow for the same row indefinitely. I don't know if this is the expected behavior in case of runtimeexception ?. I try to set the retry limit to 0 but still the same

    any help is appreciated

    regards

    ballistic_realm

  2. #2
    Join Date
    Jun 2005
    Posts
    4,232

    Default

    There was a bug in 1.1.2 that might be relevant (http://jira.springframework.org/browse/BATCH-884). I can't tell from the code you posted because you don't say who is using the RowMapper (I assume the ItemWriter). Can you upgrade to 1.1.3?

  3. #3

    Default

    Hi Dave.

    thanks for the reply

    I use the mapper in the JdbcCursorItemReader though. But i tried to upgrade to 1.1.3 as suggested by you and the program terminated on runtime exception. So i supposed it is the same issue.

    regards

    ballistic_realm

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

    Default

    Your commit interval looks pretty massive, which could be causing a lot of issues. You also haven't configured retry.

  5. #5
    Join Date
    Jan 2008
    Location
    San Diego
    Posts
    780

    Default

    Quote Originally Posted by lucasward View Post
    Your commit interval looks pretty massive, which could be causing a lot of issues.
    Yeah, looks to be the size of a signed 32 bit integer...

  6. #6

    Default

    Quote Originally Posted by lucasward View Post
    Your commit interval looks pretty massive, which could be causing a lot of issues. You also haven't configured retry.
    Hi lucas

    Yes your are right. Actually i need the step to rollback if any exception occurs. I cant think of any way except setting big value for the commit. The expected data is actually around 1000-2000 rows . Any suggestion to improve this ? I dont need retry though.

    regards

    Hendra

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

    Default

    If you need one transaction for the whole step, then using a Tasklet would be a much better option.

  8. #8

    Default

    Hi lucas,

    if i am about to use tasklet to enforce the 1 transaction in the whole step thing, how would i link the itemreader dan itemwriter ? My step is reading from text file and import into DB. Do I like have to call the itemreader.open manuallnya and then iterate through the line one by one and pass it to the itemwwriter in the execute method of the tasklet ? Or is there a way to link this automatically like the SimpleStepFactoryBean ?

    Is there any example from spring batch which is similar to this ?

    thansk

    regards

    ballistic_realm

  9. #9
    Join Date
    Jun 2005
    Posts
    4,232

    Default

    There is no directly relevant sample, but there are plenty of Tasklet implementations if that's the way you want to go. I would try some declarative transaction management, e.g. start with a transaction around Step.execute() and see if that works.

  10. #10
    Join Date
    Dec 2008
    Posts
    3

    Default

    Yes, it's expected behavious because the only exception that is set
    in your Skip logic is ValidationException, you need to add RuntimeException
    as well. That way, the record will be skipped and won't be reread.

    Hope that helps,
    Vaibhav

Posting Permissions

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