Delaying sending of mail until transaction commits

前端 未结 4 513
再見小時候
再見小時候 2021-01-23 06:01

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 on

4条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-23 06:20

    I doubt that it's possible to implement true XAResource for SMTP. There should be transaction support on the resource manager (SMTP server in this case) and I don't believe there are any. I would say your best bet is 'Last resource commit' pattern - which allows one non XA resource participate in XA transaction. Search Google, there are plenty of info. Most Java EE servers supports this.

提交回复
热议问题