質問

New to Spring batch...

I have setup a Spring batch project that reads items from a database with a custom ItemReader, transforms them into XML with an ItemProcessor and puts them on a JMS queue in an ItemWriter.

<batch:job id="sendItemsToJMS" job-repository="myJobRepository">
    <batch:step id="sendItemsToJMSStep">
        <batch:tasklet>
            <batch:chunk reader="itemReader" 
                         processor="itemProcessor" 
                         writer="itemWriter" commit-interval="10">
            </batch:chunk>
        </batch:tasklet>
    </batch:step>
</batch:job>

What needs to happen in the same transaction of a chunk is to flag the original items in the database as being sent.

Where would this logic go? Do I need to setup an extra Tasklet in the same step, as seem to be suggested in the documentation (5.2.1. TaskletAdapter)

and if so: - is it executed in the same transaction? - how would I get the list of processed IDs in the tasklet?

Cheers!

役に立ちましたか?

解決

void ItemWriteListener.afterWrite(List<? extends S> items)

Called after ItemWriter.write(java.util.List) This will be called before any transaction is committed, and before ChunkListener.afterChunk(ChunkContext)

Implements this function and - inside - perform flag update.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top