Killed Between Writes

An order service commits the order row to Postgres and then publishes an OrderPlaced event to Kafka. During a rolling deploy the process is killed between those two steps, and downstream services never learn about roughly forty orders. What is the standard fix?

A

Retry the publish in a finally block with exponential backoff so the event survives any failure of the produce call

B

Insert the event into an outbox table in the same transaction as the order row, and let a relay publish and mark it sent

C

Publish to Kafka first and commit the order row only after the broker acknowledges the write, so no event can ever be lost

D

Wrap the database commit and the Kafka produce in an XA two-phase commit so the two resources reach the same outcome atomically