문제

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