Announcement Announcement Module
Collapse
No announcement yet.
Injecting custom BackOff policy Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Injecting custom BackOff policy

    Hello,

    Newbie here ask for some direction...
    How to setup backoff policy in chunk? Since I'm expecting some exception on reading process and will retry after some time. I think to inject custom BackOff policy on my chunk. But in current xml schema, I can't find way to inject this.

    Environment on Spring-Batch 2.0.4.RELEASE

    regards,
    --
    Last edited by abbas; Nov 14th, 2009, 10:47 AM.

  • #2
    @abbas,

    BackOffPolicy can be applied to the step through the parent. Here is an example:

    Code:
    <job id="neatJob" xmlns="http://www.springframework.org/schema/batch">
        <step id="neatStep" parent="fatherStep">
            <tasklet>
                <chunk reader="neatReader" writer="neatWriter" commit-interval="${job.commit.interval}" />
            </tasklet>
        </step>
    </job>
    
    <bean id="fatherStep" class="org.springframework.batch.core.step.item.FaultTolerantStepFactoryBean">
        <property name="transactionManager" ref="transactionManager" />
        <property name="jobRepository" ref="jobRepository" />
        <property name="backOffPolicy">
        <bean class="org.springframework.batch.retry.backoff.FixedBackOffPolicy">
            <property name="backOffPeriod" value="8000" />
        </bean>
        </property>
    </bean>
    Currently however 'backOffPolicy' property is not supported by 'namespaced' configuration. I created a JIRA with a patch you can look at/apply to make the above example work:

    http://jira.springframework.org/browse/BATCH-1441

    Comment


    • #3
      litius, thanks for the response, I'll try that.

      BTW, from what I see on your patch, it could be used to create attribute for backoff-policy (by editing spring-batch.xsd?) for chunkTaskletType, is it possible or would it broke something else?

      Comment


      • #4
        @abbas,

        If you follow a discussion on JIRA, Dan (who actually wrote a parser), found that if you use a 'parent' attribute of the 'step', but will not include the 'tasklet' tag, it should work without a patch.

        I would not modify XSD just yet

        Comment


        • #5
          Hmm, another alternative, I'll give it a try too...

          Yet I still think it would be good to have backoff policy attribute in the schema...

          Comment

          Working...
          X