Spring package: Tasklet without ItemWriter

I defined my tasklet without ItemWriter as follows:

<b:tasklet>
    <b:chunk reader="baseReader" processor="baseProcessor"  commit-interval="100" />
</b:tasklet>

and I got this error:

Configuration problem: the element <b:chunk/>has neither the 'writer' attribute nor the element <writer/>.

Do you have any ideas? Thanks

+3
source share
2 answers

We can define a piece without writing (only reader + processor), I succeeded. It seems that in order to convey the writer's step containing the piece, it should inherit the parents of the abstract step, for example:

    <b:step id="task" parent="Task">
        <b:tasklet>
            <b:chunk reader="baseReader" processor="baseProcessor" commit- interval="100" />
        </b:tasklet>
    </b:step>

    <b:job id="batch" parent="Batch">
        <b:step id="etape" parent="task" />
    </b:job>

Problem solved, thanks!

+4
source

Well, in a piece, the reader and writer are MANDATORY! however, ItemProcessor is optional.

:

5.1.1.

Step, , . , Spring Batch:

<job id="sampleJob" job-repository="jobRepository">
<step id="step1">
    <tasklet transaction-manager="transactionManager">
        <chunk reader="itemReader" writer="itemWriter" commit-interval="10"/>
    </tasklet>
</step>

, :

reader - ItemReader, .

writer - ItemWriter, , ItemReader.

transaction-manager - Spring PlatformTransactionManager, .

job-repository - JobRepository, StepExecution ExecutionContext ( ). ( a) ; .

commit-interval - , .

, job-repository "jobRepository", - "transactionManger". , ItemProcessor , , .

+5

All Articles