我想在提交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不适用于春季批处理。
springboot和spring batch之间有什么不同的spring上下文吗??
或者对@TransactionalEventListener来说,spring batch有什么设置吗??
发布于 2020-04-02 09:50:29
ApplicationEventPublisher发布的
Spring批处理不会拦截这些事件。您需要让侦听器参与一个步骤生命周期事件(读之前/之后、写之前/之后等等)。
--我想在春批提交之后处理一些东西。
您可以为此使用一个ChunkListener#afterChunk,在提交事务后调用它。
https://stackoverflow.com/questions/60966901
复制相似问题