Transactional Outbox for Domain Events
Design a transactional outbox so we do not write to the database and then fail to publish the event, or publish the event and then roll back the write. CONTEXT Database: [POSTGRES] Publisher: [QUEUE NAME] Events: [LIST THE 3 EVENTS] Consumer requirement: at-least-once, handlers must be idempotent. DELIVER 1) The outbox table: id, aggregate type, aggregate id, type, payload jsonb, created_at, published_at. 2) The application transaction: business write and outbox insert commit together. Show the pseudocode. 3) The publisher loop: select unpublished for update skip locked, publish, mark published. What happens if publish succeeds and the mark fails (duplicate delivery) and why the consumer can stand it. 4) The consumer idempotency key (event id) and the table it uses. 5) Operational bits: lag metric, a poison event that fails forever, and how a human replays one event. 6) What this does not solve: ordering across aggregates. Say that. Do not dual-write to the queue inside the request without the outbox.
🌟 Example Output / Preview
Prompt Metadata
Primary Use Cases:
- •Legacy code modernization & technical refactoring
- •Full-stack layout generation & component structuring
- •CI/CD workflow automation & unit/E2E testing suites
Associated Tags:
💡 Pro Tips & Advice
1. Use bracketed items: Be sure to fill out all [PLACEHOLDER] elements with specific details before sending the prompt to the AI model.
2. Adjust temperature: For creative tasks, set AI temperature higher (e.g., 0.8), or lower (e.g., 0.2) for strict coding/technical tasks.
🔗 Related AI Prompts
Full SaaS Landing Page Build Spec (SEO + Conversion)
You are a Staff Product Designer + Frontend Engineer + SEO strategist. Build a complete, production-ready marketing landing page f...
SaaS Analytics Dashboard Full Build Spec
You are a Principal Product Designer + Frontend Lead. Design and specify a complete [LIGHT | DARK] analytics dashboard for [PRODUC...
SaaS Admin Panel Dashboard Build Spec
Design a full internal Admin Dashboard for [PRODUCT_NAME] used by [ADMIN_ROLE: support | ops | super-admin]. --- 🎯 CONTEXT Adm...