延迟发送邮件直到交易提交 [英] Delaying sending of mail until transaction commits

查看:128
本文介绍了延迟发送邮件直到交易提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有人有一个很好的教程或一些建议如何实现自己的XAResource?我需要Spring的MailSender是交易的,所以邮件只会在事务提交之后被发送,似乎没有任何现有的事务包装器。

解决方案

如果您只需要等待提交,就像您在评论中说的那样,您可以使用 TransactionSynchronizationManager.registerSynchronization ) 来触发电子邮件发送。


Does anyone have a good tutorial or some advice on how to implement one's own XAResource? I need Spring's MailSender to be transactional, so that the mail will only be sent once the transaction commits, and it seems there isn't any existing transactional wrapper.

解决方案

If you just need to wait for the commit, as you say in a comment, you can investigate using TransactionSynchronizationManager.registerSynchronization() to trigger email sending on commit.

这篇关于延迟发送邮件直到交易提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆