Results 1 to 3 of 3

Thread: Tasklet without ItemReader & ItemWriter ?

  1. #1
    Join Date
    Sep 2010
    Posts
    28

    Question Tasklet without ItemReader & ItemWriter ?

    <batch:job id="extract">
    <!-- Step One is to Create the File & store it locally -->
    <batch:step id="generateFile" >
    <batch:tasklet>
    <batch:chunk reader="reader" writer="writer" commit-interval="20" />
    </batch:tasklet>
    </batch:step>
    <!-- Step Two is to Create the File & store it locally -->
    <batch:step id="transferFile">
    <batch:tasklet >
    <batch:chunk reader="dummyItemReader" processor="FileFTP" writer="dummyItemWriter" commit-interval="5" />
    </batch:tasklet>
    </batch:step>
    </batch:job>

    I am using Spring batch 2.1.5
    Please look at the above Code. Here i am having 2 steps
    1. To generate the file by fetching the data from tables.
    2. FTP the generated file to some destination.
    In the step 2, i am using dummy reader & writer just because those are mandatory in a tasklet even though it is not serving any purpose.
    I have added the logic to FTP the file in process method of the processor(FileFTP class).

    Is there any way so that i can avoid the dummy reader & writer which are of no use?
    Or is there any way where i can call a method in that step ?(i can add the whole code which is present in proces method of processor into that method)
    Last edited by kamath_sv; Feb 15th, 2011 at 01:42 AM.

  2. #2
    Join Date
    Dec 2005
    Location
    Lyon, France
    Posts
    311

    Default

    don't use a chunk-oriented step for the FTP part, a custom tasklet would be fine.

  3. #3
    Join Date
    Sep 2010
    Posts
    28

    Default

    Thanks i tried Method invoking tasklet & passed values through latebinding ( using #{jobExecutionContext['currentRunningJob']} )

    it worked as a charm...

Posting Permissions

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