Hi all,
My use case is that I'm inserting a bunch of rows in a table in a chunk, and as part of the chunk's commit, I need to call a sproc that derives a bunch more (denormalized) data from the inserted rows.
According to the ChunkListener interface, beforeChunk() is called after the chunk and its transaction start, and afterChunk() is called after the chunk is executed and the transaction is committed. Additionally, there's no Chunk/Step/JobExectution context passed into these methods. It's as though I need an interface called TransactionalChunkListener that looks like this:How do I achieve this in Spring Batch 2.1.x & later?Code:public interface TransactionalChunkListener { public void beforeChunkBeforeTransactionStart(ChunkContext cx); public void beforeChunkAfterTransactionStart(ChunkContext cx); public void afterChunkBeforeTransactionCommit(ChunkContext cx); // this is the one I need public void afterChunkAfterTransactionCompletion(ChunkContext cx, boolean committed); }
-matthew


Reply With Quote
