Announcement Announcement Module
Collapse
No announcement yet.
Quartz and Spring Batch: ItemReader receives the same parameters on each trigger. Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Quartz and Spring Batch: ItemReader receives the same parameters on each trigger.

    I'm triggering Spring Batch jobs using Quartz and am seeing that for each job execution resulting from a Quartz trigger, my ItemReader always receives the job parameters corresponding to the first execution.

    I've had a look through the Spring Batch code, but as I haven't had much experience with the internals, I thought I'd post here in case someone can point out any obvious mistakes.

    Thanks in advance,

    John Logan

    Here follow the details:

    The attached log excerpt illustrates the problem. It shows two job executions, one for each instance of the same job. The log message containing "Starting step" is in the constructor for the ItemReader, so it seems that the step scope is being honored. However, the 'now' parameter logged in the second "Starting step" message doesn't correspond to the job parameter for the second execution; rather, it's exactly the same as the job parameter for the first execution. Any subsequent executions of the same job all wind up with the same 'now' parameter.

    We used the Quartz code from the Spring Batch samples pretty much verbatim for launching jobs from Quartz triggers; one twist is that we are using a RetryListener to catch and retry errors. The invocation of the scheduler looks like:

    Code:
    java -cp ./target/lib/*:./target/batch-1.1.0-SNAPSHOT.jar org.springframework.batch.core.launch.support.JobRegistryBackgroundJobRunner classpath:/META-INF/spring/quartz-job-launcher-context.xml classpath:/jobs/testJob.xml

  • #2
    Problem solved: Using downrev Spring framework components.

    I spent this morning trying to package up a simplified example that duplicated the issue, and when I ran that example, everything worked properly - the job parameters in the ItemReader construction coincided with the parameters for the job execution.

    In creating the example, I noticed and fixed an inconsistency in the versions of my Spring framework components: spring-context, spring-aop, spring-test, and spring-jdbc were using 3.0.2-RELEASE, while the other Spring framework components were using 3.0.5-RELEASE.

    When I reintroduced this inconsistency into my simplified project, I saw the botched behavior of my original project.

    Comment

    Working...
    X