Delaying sending of mail until transaction commits

前端 未结 4 514
再見小時候
再見小時候 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:22

    One other option next to the one mentioned by gpeche, is sending a transactional JMS message from within the transaction. Then let the message listener (like e.g. a MDB bean) send the email.

    Another trick in EJB is scheduling a timer from within a transaction. The timer is also transactional and will only be started when the transaction commits. Simply use a timer with timeout = 0, so it will start immediately after the transaction commits.

提交回复
热议问题