Skip to main content

Claude/ChatGPT Prompt to Build a Spring Boot + Kafka Event System

Build an event-driven architecture with Spring Boot and Kafka, including event schemas, consumers, producers, and dead-letter topics.

Fill in the placeholders

Edit the values, then copy your finished prompt.

Your Prompt
prompt.txt

                                

What this prompt does

This prompt asks the AI to design an event-driven system with Spring Boot and Apache Kafka for [domain], focused on the reliability details that decide whether events are lost. For your [events] it produces Avro or JSON schema definitions registered in [schema_registry], a producer using the transactional outbox pattern, a consumer with [consumer_group] configuration, dead-letter handling with [max_retries] retries, exactly-once semantics config, a backward/forward-compatible versioning strategy, Spring Cloud Stream bindings, EmbeddedKafka integration tests, consumer-lag monitoring, and a Kafka Connect sink projecting to [sink_target] — with docker-compose for Kafka, Zookeeper, and the schema registry.

The structure works because Kafka systems quietly lose data when the outbox, retries, and dead-letter paths are not designed deliberately. Locking in reliable publishing, exactly-once semantics, and consumer-lag monitoring before writing the first producer prevents the failure modes that are hardest to debug after the fact. The schema-registry and versioning steps matter just as much, since an event format that changes without a compatibility plan can break every downstream consumer at once, long after the producer change shipped.

When to use it

  • You are building a Kafka-based pipeline for [domain] and need reliable publishing, not fire-and-forget.
  • You want the transactional outbox pattern so events and database changes commit atomically.
  • You need dead-letter handling and retries so a poisoned event does not block a partition.
  • You want a schema registry and a compatibility strategy so event evolution stays safe.
  • You need consumer-lag monitoring to catch consumers falling behind before it becomes an incident.
  • You want a projection of events into [sink_target] for search or read models.

Example output

Expect schema files for each event registered with [schema_registry], a producer service implementing the outbox pattern, a consumer with group and retry config, dead-letter topic handling, exactly-once configuration, Spring Cloud Stream bindings, EmbeddedKafka tests, lag-monitoring setup, a Kafka Connect sink config for [sink_target], and a docker-compose file for the full stack. It is delivered as an interconnected producer/consumer system rather than a single class.

Pro tips

  • Name your real [events] so schemas and topic structure reflect your domain rather than placeholders.
  • Choose [schema_registry] and format (Avro vs JSON) deliberately, since compatibility checking behaves differently between them.
  • Keep [max_retries] modest and pair it with the dead-letter topic; endless retries on a poison message stall the partition.
  • Set [consumer_group] strategy to match how you scale consumers, as partition assignment depends on it.
  • Treat the outbox pattern as essential when events must stay consistent with database writes — do not skip it for convenience.
  • Iterate by asking how a specific schema change stays backward-compatible, or how a failed event flows to the dead-letter topic and back.

Frequently Asked Questions

Why use the transactional outbox pattern?
Because publishing an event and committing a database change as two separate operations can leave them out of sync if one fails. The outbox pattern writes the event into the same transaction as the data change, so the event is only published if the data actually committed.
Does it support exactly-once semantics?
Yes, the prompt asks for exactly-once configuration on the Kafka producers and consumers. In practice exactly-once depends on idempotent producers and transactional reads, so the design wires those together rather than assuming duplicates can never occur.
How are failed events handled?
Through a dead-letter topic combined with `[max_retries]` retry attempts. After the retries are exhausted, the event moves to the dead-letter topic so it stops blocking the partition and can be inspected or replayed later without losing the message.
Can I project events into a search system?
Yes. The prompt includes a Kafka Connect sink to `[sink_target]`, defaulting to Elasticsearch for order search. This builds a read-optimized projection from your event stream, separate from the source-of-truth services, so search load does not hit the primary database.
Engr Mejba Ahmed

Need this built for real?

Engr Mejba Ahmed

AI Developer · Software Engineer

I'm Mejba — I design and ship production AI systems, automations, and full-stack apps. If you want this turned into a working solution for your team, let's talk.

More in Java & Spring Boot Prompts

Engr Mejba Ahmed

Engr Mejba Ahmed

Claude Code Expert · Online

👋

Hey there!

Quick Actions

WhatsApp Instant reply

Chat on WhatsApp

+880 1723 741224 · Instant reply

Popular Questions

Engr Mejba Ahmed is connected
Engr Mejba Ahmed is typing...
Engr Mejba Ahmed avatar

✉ Want me to follow up? Drop your email

Engr Mejba Ahmed avatar

📞 Connect Directly

Choose how you'd like to reach me

WhatsApp

+880 1723 741224

Email

[email protected]

✓ Details sent! I'll get back to you shortly.

Powered by OpenAI

335+

Blog Posts

25

AI Courses

63

Projects

Services & Expertise

Pricing & Process

Learning & Resources

Connect & Support