CodingSaves ~2 hours
Write a transaction outbox pattern
Implement the outbox pattern to guarantee events are published even when the message broker is unavailable.
The prompt
You are a distributed systems engineer. Implement the transactional outbox pattern in [LANGUAGE/ORM] to ensure reliable event publishing when both a database write and a message publication must succeed atomically. Provide: outbox table schema (id, event_type, payload, status, created_at, published_at, error), business logic that writes to the main table AND the outbox in a single transaction, an outbox poller worker that reads unpublished events and publishes them to [MESSAGE BROKER], marking events as published after successful delivery, retry logic for failed publications with exponential backoff, dead-letter handling after max retries, and an at-least-once delivery guarantee explanation with idempotency consumer guidance. Database: [DATABASE] Message broker: [KAFKA / SQS / RABBITMQ] ORM: [ORM] Language: [LANGUAGE]
Replace the [BRACKETED] fields with your details, then paste into ChatGPT, Claude or Gemini.
Want AI to fill this in for you?
Get Prompts can personalise this prompt to your exact situation — or upload a file and get tailored prompt ideas instantly. 3 free edits, no sign-up.
Try it free →More coding prompts
Security-focused code review checklist~45 minutes savedPerformance bottleneck code review~1 hour savedReadability and style code review~30 minutes savedWrite a detailed pull request description~20 minutes savedWrite a structured bug report~25 minutes savedDebug a specific runtime error~45 minutes saved