Announcement Announcement Module
Collapse
No announcement yet.
Itemreader that does nothing Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    Sorry but i am not using annotation based approach.

    Comment


    • #17
      The @BeforeStep annotation is the same thing as implementing StepExecutionListener and saying:
      Code:
      public void beforeStep(StepExecution stepExecution) {
          this.storeStepExecution(stepExecution);
      }

      Comment


      • #18
        How to define a listener for a tasklet then? I am very new to spring batch and have not referred much of documentation thats why asking such questions..

        I am attaching some code snippet for my job, please suggest

        <bean id="batchjob" parent="simpleJob">
        <property name="name" value="batch job" />
        <property name="steps">
        <list>
        <bean id="step1" parent="simpleStep">
        <property name="itemReader"
        ref="initialReader" />
        <property name="itemProcessor" ref="verifyProcessor" />
        <property name="itemWriter" ref="dummyItemWriter" />
        <property name="commitInterval" value="1000" />
        <property name="listeners">
        <list>
        <ref bean="verifyProcessor" />
        <ref bean="xmlOutputFile" />
        </list>
        </property>
        </bean>

        <bean id="step2" parent="simpleStep">
        <property name="itemReader" ref="dummyItemReader" />
        <property name="itemProcessor" ref="dummyItemProcessor" />
        <property name="itemWriter" ref="actualWriter" />
        <property name="commitInterval" value="1000" />
        <property name="listeners">
        <list>
        <ref bean="dummyItemReader" />
        <ref bean="actualWriter" />
        <ref bean="xmlOutputFile" />
        </list>
        </property>
        </bean>

        <!--
        <bean id="step2" parent="taskletStep"> <property name="tasklet"
        ref="actualWriter" /> </bean>
        -->
        </list>
        </property>
        </bean>

        Comment


        • #19
          Code:
          public class MyTasklet implements Tasklet, StepExecutionListener { ... }

          Comment


          • #20
            i meant in the config, do we have listeners property in tasklet too as found in step

            such as

            <property name="listeners">
            <list>
            <ref bean="verifyProcessor" />
            <ref bean="xmlOutputFile" />
            </list>
            </property>

            Comment


            • #21
              The TaskletStep has a property "stepExecutionListeners"

              Comment


              • #22
                I don't think you even need to mess with injecting the StepExecution, just use late binding to put the values you want into the tasklet. Something like ${jobExecutionContext[my.summary.key]}

                There's a section in the document explaining how to do this. In fact, before there's anymore back and forth, I think you should really read through the first three chapters. All of these topics are explained in detail there. If you don't feel like you understand after reading them, please post here. We're always working to make the documentation better, and if you can't understand it, I'd like to know why, so that I can address any issues. (May provide more examples, etc)

                Comment


                • #23
                  Hi there,

                  By any chance can anyone tell me why my job is getting executed again and again. I mean whenever i start my application, the job starts automatically (its single job) and the reader is executed again and again without going to the processor or the writer items.

                  Comment


                  • #24
                    Hi All,

                    Finally i am through with it. I have implemented tasklet and have got my job batch running successfully.

                    Following is my final configuration

                    <!-- Job Configuration - Start-->
                    <bean id="batchJob" parent="simpleJob">
                    <property name="name" value="Batch Job" />
                    <property name="steps">
                    <list>
                    <bean id="step1" parent="simpleStep">
                    <property name="itemReader" ref="initialJpaPagingItemReader" />
                    <property name="itemProcessor" ref="verifyItemProcessor" />
                    <property name="itemWriter" ref="dummyItemWriter" />
                    <property name="commitInterval" value="1000" />
                    <property name="listeners">
                    <list>
                    <ref bean="dummyItemWriter" />
                    <ref bean="xmlOutputFile" />
                    </list>
                    </property>
                    </bean>

                    <bean id="step2" parent="taskletStep">
                    <property name="tasklet" ref="ProcessingSummaryXmlWriter" />
                    <property name="stepExecutionListeners">
                    <list>
                    <ref bean="ProcessingSummaryXmlWriter" />
                    <ref bean="xmlOutputFile" />
                    </list>
                    </property>
                    <property name="streams">
                    <list>
                    <ref bean="staxEventItemWriter" />
                    </list>
                    </property>
                    </bean>

                    </list>
                    </property>
                    </bean>
                    <!-- Job Configuration - End-->

                    I would like to thank DHGarrette and lucasward for there valuable support.
                    Last edited by puneetswarup; Mar 16th, 2009, 01:42 AM.

                    Comment

                    Working...
                    X