首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >@TransactionalEventListener在春季批处理

@TransactionalEventListener在春季批处理
EN

Stack Overflow用户
提问于 2020-04-01 08:46:39
回答 1查看 497关注 0票数 1

我想在提交spring batch之后处理一些事情。

我试过这个例子(https://dzone.com/articles/transaction-synchronization-and-spring-application)。

该示例在springboot上非常有效,就像这样的流。

代码语言:javascript
复制
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上并不像预期的那样工作。

代码语言:javascript
复制
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

我怀疑@TransactionalEventListenerApplicationEventPublisher不适用于春季批处理。

springbootspring batch之间有什么不同的spring上下文吗??

或者对@TransactionalEventListener来说,spring batch有什么设置吗??

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-04-02 09:50:29

ApplicationEventPublisher发布的

  1. 一些更新查询和事件发布

Spring批处理不会拦截这些事件。您需要让侦听器参与一个步骤生命周期事件(读之前/之后、写之前/之后等等)。

--我想在春批提交之后处理一些东西。

您可以为此使用一个ChunkListener#afterChunk,在提交事务后调用它。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60966901

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档