Announcement Announcement Module
Collapse
No announcement yet.
How to make Spring-Batch job restartable Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to make Spring-Batch job restartable

    Hello Spring-Batch experts,

    I have a very simple Spring-Batch application to copy one table data from one database to the other. The application is only consisted of 4 programs RowMapper, PrepareStatementSetter, Patitioner and main entry.
    The main program is calling Spring-Batch JobLauncherTestUtils. Basically all elements are using Spring-Batch default implementation and we don't have specific implementation. The application runs fine. The only thing
    is lacking of the restart-ability. The test that I have done is to kill the job in the middle, then re-run the application. I thought the application re-run will start from the failed point, somehow it doesn't. Every time it restarts from the beginning, meaning if the app has inserted 100 rows, next time it does not start from 101,
    instead it starts from the very beginning.

    The configuration looks like:

    <job id="partitionJdbcJob" xmlns="http://www.springframework.org/schema/batch">
    <step id="step">
    <partition step="step1" partitioner="partitioner" >
    <handler grid-size="7" task-executor="taskExecutor" />
    </partition>
    </step>
    </job>

    <bean id="partitioner" class="xxx.yyy.zzz.RangePartitioner">
    <property name="dataSource" ref="sourceDataSource" />
    <property name="table" value="some_big_table" />
    <property name="column" value="OID" />
    </bean>

    ....

    Any thoughts or suggestions?

    Many thanks,
    /cuitsp

  • #2
    With remote partitioning, you'll need to stamp your records as being processed in some way (since there isn't a global state maintained across all partitions). When using databases, typically this is handled with a processed column that is updated via a ChunkListener with each commit.

    Comment

    Working...
    X