How do you avoid losing an event when saving an order?
A service creates an order in PostgreSQL and publishes an event to a message broker. Sometimes the order is saved, but the message never reaches the broker. The reverse can happen too: the message is published, but the order transaction rolls back. How would you fix this design without using a distributed transaction across PostgreSQL and the broker? Explain what happens if publishing fails, what delivery guarantees the system provides, and how a consumer should handle duplicate events.
ExplainTransactions and locksMiddleBackendData EngineerQA