messaging

Implements Kafka or RabbitMQ messaging patterns in Spring Boot services.

Updated Jun 25, 2026
One-click install
npx skills add https://github.com/oriddd/ai-toolkit --skill messaging-oriddd
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: messaging
Source: https://github.com/oriddd/ai-toolkit/tree/main/copilot/public/skills/messaging
Command: npx skills add https://github.com/oriddd/ai-toolkit --skill messaging-oriddd

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Publishing events directly alongside database writes causes lost or duplicated messages when one side fails, and naive consumers reprocess duplicate deliveries. This Skill provides the canonical Spring Boot patterns for reliable async messaging so services publish and consume domain events without data loss or double-processing. ## Core Features & Use Cases - Transactional Outbox: Writes events to an outbox table in the same database transaction as the entity, then relays them asynchronously to the broker, eliminating the save-then-publish race. - Idempotent Consumer: Deduplicates incoming events via a processed-events table with an event-id header, making at-least-once delivery safe. - Dead-Letter & Schema Management: Configures retry with exponential backoff, dead-letter topics with alerting, and versioned Avro/Protobuf/JSON-Schema contracts checked for compatibility. - Use Case: When adding a Kafka consumer for document-created events to a Spring Boot service, apply this Skill to get the idempotent listener, outbox-backed producer, DLT policy, and partition-key strategy in one pass. ## Quick Start Apply the messaging skill to add an idempotent Kafka consumer and transactional outbox producer for document events in this Spring Boot service.

Frequently Asked Questions about messaging

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

FAQPage Schema
How do I publish Kafka events reliably from a Spring Boot service?

Use the transactional outbox pattern: write the event to an outbox table in the same database transaction as the entity, then have a scheduled relay publish pending rows to the broker. This avoids the race where the publish succeeds but the database commit fails.

How do I make a Kafka consumer idempotent in Spring Boot?

Assign every event a unique event-id header and insert it into a processed-events table with INSERT ON CONFLICT DO NOTHING inside the consumer's business transaction. If the row already exists, skip processing, making at-least-once delivery safe.

Avro vs Protobuf vs JSON Schema for Kafka event schemas?

Use Avro with Schema Registry for strict evolution and large fanout, Protobuf for polyglot consumers or gRPC environments, and JSON Schema for small teams without a registry. All schemas must stay forward and backward compatible during normal evolution.

Why does my Kafka consumer process duplicate messages?

Brokers guarantee at-least-once delivery, so retries, rebalances, or outbox relay re-publishes cause duplicates. Deduplicate with a processed-events table keyed by event-id and commit offsets only after the business transaction commits.

When should I not use messaging for service communication?

Never use messaging for request/response interactions; use HTTP or gRPC instead. Also avoid publishing directly from HTTP handlers without an outbox, and never block consumer threads on slow synchronous downstream calls.