This pattern has the following benefits:
2PC is not used
Messages are guaranteed to be sent if and only if the database transaction commits
Messages are sent to the message broker in the order they were sent by the application
This pattern has the following drawbacks:
Potentially error prone since the developer might forget to publish the message/event after updating the database.
This pattern also has the following issues:
The Message Relay might publish a message more than once. It might, for example, crash after publishing a message but before recording the fact that it has done so. When it restarts, it will then publish the message again. As a result, a message consumer must be idempotent, perhaps by tracking the IDs of the messages that it has already processed. Fortunately, since Message Consumers usually need to be idempotent (because a message broker can deliver messages more than once) this is typically not a problem.
https://microservices.io/patterns/data/transactional-outbox.html