@TransactionalEventListener 在 spring 个批次
@TransactionalEventListener at spring batch
我想在 spring batch
提交后处理一些东西。
我试过这个例子 (https://dzone.com/articles/transaction-synchronization-and-spring-application)。
该示例在 springboot
上完美运行,就像这个流程一样。
1. some update query and event publish by ApplicationEventPublisher
2. some update query and event publish by ApplicationEventPublisher
3. some update query and event publish by ApplicationEventPublisher
4. commit
5. after commit logic I maked
6. after commit logic I maked
7. after commit logic I maked
但是在 spring batch
上没有按预期工作。
1. some update query and event publish by ApplicationEventPublisher, and after commit logic
2. some update query and event publish by ApplicationEventPublisher, and after commit logic
3. some update query and event publish by ApplicationEventPublisher, and after commit logic
3. commit
我怀疑 @TransactionalEventListener
或 ApplicationEventPublisher
不适用于 spring 批处理。
springboot
和 spring batch
之间的上下文 spring 有什么区别吗??
或者@TransactionalEventListener
,spring batch
有设置吗??
- some update query and event publish by ApplicationEventPublisher
Spring Batch 不会拦截那些事件。您需要让您的侦听器参与步骤生命周期事件之一(before/after 读取、before/after 写入等)
I want to process something after commit on spring batch.
您可以为此使用 ChunkListener#afterChunk
,它会在事务提交后调用。
我想在 spring batch
提交后处理一些东西。
我试过这个例子 (https://dzone.com/articles/transaction-synchronization-and-spring-application)。
该示例在 springboot
上完美运行,就像这个流程一样。
1. some update query and event publish by ApplicationEventPublisher
2. some update query and event publish by ApplicationEventPublisher
3. some update query and event publish by ApplicationEventPublisher
4. commit
5. after commit logic I maked
6. after commit logic I maked
7. after commit logic I maked
但是在 spring batch
上没有按预期工作。
1. some update query and event publish by ApplicationEventPublisher, and after commit logic
2. some update query and event publish by ApplicationEventPublisher, and after commit logic
3. some update query and event publish by ApplicationEventPublisher, and after commit logic
3. commit
我怀疑 @TransactionalEventListener
或 ApplicationEventPublisher
不适用于 spring 批处理。
springboot
和 spring batch
之间的上下文 spring 有什么区别吗??
或者@TransactionalEventListener
,spring batch
有设置吗??
- some update query and event publish by ApplicationEventPublisher
Spring Batch 不会拦截那些事件。您需要让您的侦听器参与步骤生命周期事件之一(before/after 读取、before/after 写入等)
I want to process something after commit on spring batch.
您可以为此使用 ChunkListener#afterChunk
,它会在事务提交后调用。