Skip to content

Publish CourseCreated to Kafka #2

@maalayat

Description

@maalayat

Parent

#1 — Migrate domain event bus from RabbitMQ to Kafka

What to build

Full producer path: when CourseCreator creates a Course, the CourseCreatedDomainEvent is published to the "course.created" Kafka topic. The KafkaEventBus replaces RabbitMqEventBus as the primary EventBus implementation and falls back to MySqlEventBus on persistent KafkaException after producer retries are exhausted.

Domain events are serialized to a JSON envelope (data/id/type/occurred_on/attributes) using a Jackson mix-in at the infrastructure level — no Jackson annotations on domain classes, no reflection, no toPrimitives() or fromPrimitives().

The DomainEvent base class is simplified (remove toPrimitives(), toJson(), fromPrimitives(), implements Serializable), CourseCreatedDomainEvent loses its no-arg constructor and serialization boilerplate, and the @DomainEventSubscriber annotation is deleted.

All RabbitMQ producer infrastructure is removed.

Acceptance criteria

  • DomainEvent base class has no toPrimitives(), toJson(), or fromPrimitives() methods
  • CourseCreatedDomainEvent has no no-arg constructor and no serialization methods
  • KafkaEventBus (annotated @Primary) publishes each DomainEvent to a Kafka topic matching its eventName()
  • KafkaEventBus falls back to MySqlEventBus when KafkaTemplate.send() throws after retries
  • Integration test with embedded Kafka broker proves event lands on the "course.created" topic
  • DomainEventKafkaSerializer unit test proves round-trip (serialize → deserialize → equal event)
  • spring-boot-starter-amqp and com.google.guava:guava removed from build.gradle
  • spring-kafka added to build.gradle
  • All 7 RabbitMQ infrastructure files deleted
  • @DomainEventSubscriber annotation deleted
  • NamingUtil.java deleted
  • RabbitMqEventBusConfiguration deleted

Blocked by

None — can start immediately

Metadata

Metadata

Assignees

No one assigned

    Labels

    ready-for-agentFully specified, ready for an AFK agent

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions