This is a common period of the problem, not to mention DDD
In general, on any system that requires a reaction (such as a web server), any lengthy actions must be processed asynchronously for the startup process.
This means a queue.
Rolling back your transaction should remove the item from the queue.
Of course, now you need additional mechanisms to handle the situation when the item in the queue is not processed - that is, e-mail is not sent - you also need to enable this in your startup codes - followed by the RELY process on the previous process that already happened, in some then the moment there will be a problem.
In short, your queue mechanism must be transactional and allow retries, and you need to think of the whole chain of events as a workflow.
Bonyt
source share