Announcement Announcement Module
Collapse
No announcement yet.
late-binding for ChunkOrientedTasklet does not work Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • late-binding for ChunkOrientedTasklet does not work

    Hi,

    I cannot get late-binding working in the following configuration using Spring Batch 2.2.0.RC1.

    Code:
    <batch:step id="splitgidcsv">
        <batch:tasklet start-limit="3">
            <batch:chunk commit-interval="#{jobParameters['commit.interval']}" skip-limit="10000"
                reader="gidFromCsvReader" writer="gidToCsvMultiResourceWriter">
            </batch:chunk>
        </batch:tasklet>
    </batch:step>

    Code:
    @Test
    public void testLaunchJob4() throws Exception {
        jobLauncher.run(fullsyncusers, new JobParametersBuilder()
            .addString("date", (new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss.S" )).format(new Date()))
            .addString("commit.interval", "10")
            .toJobParameters());
    }
    DEBUG log shows the following entries:
    Code:
    1594 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory  - Ignoring constructor [public org.springframework.batch.core.job.flow.support.state.StepState(java.lang.String,org.springframework.batch.core.Step)] of bean '(inner bean)#57': org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name '(inner bean)#57': Unsatisfied dependency expressed through constructor argument with index 0 of type [java.lang.String]: Could not convert constructor argument value of type [org.springframework.batch.core.step.tasklet.TaskletStep] to required type [java.lang.String]: Failed to convert value of type 'org.springframework.batch.core.step.tasklet.TaskletStep' to required type 'java.lang.String'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [org.springframework.batch.core.step.tasklet.TaskletStep] to required type [java.lang.String]: no matching editors or conversion strategy found
    1594 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory  - Finished creating instance of bean '(inner bean)#57'
    1594 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory  - Finished creating instance of bean '(inner bean)#57'
    1594 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory  - Creating instance of bean '(inner bean)#58'
    1594 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory  - Creating instance of bean '(inner bean)#58'
    1594 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory  - Returning cached instance of singleton bean 'splitgidcsv'
    1625 [main] INFO  org.springframework.batch.core.step.builder.FaultTolerantStepBuilder  - Setting commit interval to default value (1)
    Any ideas what's going wrong here?

    Thanks in advance,
    Elmar
    Last edited by elster; Apr 9th, 2013, 07:25 AM.

  • #2
    Hi again,

    This problem only occurs using 2.2.0.RC1. It works as expected in 2.1.9. Was the late-binding feature in ChunkOrientedTasklet removed in 2.2.0? Afair it was just added in 2.1.7...

    Br,
    Elmar

    Comment


    • #3
      Two things here:
      1. I ran a test and the functionality does work fine in 2.2.0.RC1. I am able to inject the commit interval the same way you are attempting in your test case.
      2. What I think is causing that log message is that when the FaultTolerantStepBuilder executes, the commit interval hasn't been set yet. It will be set by the StepScope later. So while that log message may be a bit confusing, I would expect the commit interval to be set correctly in your job upon execution.

      Comment

      Working...
      X