go-outbox-pattern

Scaffold the transactional outbox pattern for Go microservices with Kafka publishing.

Updated Jan 17, 2026
One-click install
npx skills add https://github.com/saddam-eng-tech/ai-agent-skills --skill go-outbox-pattern
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: go-outbox-pattern
Source: https://github.com/saddam-eng-tech/ai-agent-skills/tree/main/go-outbox-pattern
Command: npx skills add https://github.com/saddam-eng-tech/ai-agent-skills --skill go-outbox-pattern

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill addresses the challenge of ensuring event delivery consistency between a database write and a message queue publish, preventing data loss even during system crashes.

Core Features & Use Cases

  • Transactional Writes: Ensures database writes to both the domain table and the outbox table occur within a single atomic transaction.
  • Reliable Publishing: Implements a polling worker that reliably publishes events from the outbox table to Kafka.
  • Idempotency: Includes mechanisms for consumer idempotency to handle duplicate event deliveries.
  • Use Case: When a new user is created in a Go microservice, this pattern guarantees that the user creation event is published to Kafka if and only if the user record is successfully saved to the database.

Quick Start

Scaffold the transactional outbox pattern for a Go microservice, including database migrations, transactional writes, a polling worker, and a Kafka publisher.

Frequently Asked Questions about go-outbox-pattern

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I ensure atomic database writes and reliable Kafka publishing in Go microservices?

The transactional outbox pattern ensures reliable Kafka publishing by writing domain entities and outbox events within a single atomic database transaction, preventing data loss even during application crashes.

What is the transactional outbox pattern and when do I need it for event-driven architecture?

The transactional outbox pattern solves event delivery consistency by storing events in a database table alongside domain data. You need it when application crashes might cause lost messages between database commits and Kafka publishes.

How do I scaffold a polling worker for event dispatch from a database to Kafka?

You can scaffold a polling worker that reliably publishes events from the outbox table to Kafka. This worker continuously checks the database for unpublished events and dispatches them to the message broker.

Does the outbox pattern provide idempotency for duplicate Kafka event deliveries?

Yes, the outbox pattern implementation includes consumer idempotency mechanisms to handle duplicate event deliveries. This ensures downstream services process repeated messages safely without data corruption.

What is the best way to guarantee event delivery consistency in Go microservices without dual writes?

The transactional outbox pattern eliminates dual write problems by atomically committing domain data and outbox events in the same transaction. A separate polling worker then reliably publishes committed events to Kafka.

Why does my Kafka consumer receive duplicate events when the microservice crashes mid-publish?

Application crashes during Kafka publishing can cause duplicate deliveries because the outbox polling worker might resend events. The built-in idempotency checks ensure consumers safely handle these duplicate messages.