Results 1 to 5 of 5

Thread: Injecting custom BackOff policy

  1. #1
    Join Date
    Aug 2009
    Posts
    4

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

  2. #2
    Join Date
    Apr 2008
    Location
    Philadelphia, US
    Posts
    198

    Arrow

    @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
    Humans are stateful and mutable beings that have no problems processing many things concurrently and share state with others + they are usually "coupled"

  3. #3
    Join Date
    Aug 2009
    Posts
    4

    Default

    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?

  4. #4
    Join Date
    Apr 2008
    Location
    Philadelphia, US
    Posts
    198

    Arrow

    @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
    Humans are stateful and mutable beings that have no problems processing many things concurrently and share state with others + they are usually "coupled"

  5. #5
    Join Date
    Aug 2009
    Posts
    4

    Default

    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...

Posting Permissions

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