Skip to content

Consume CourseCreated from Kafka #3

@maalayat

Description

@maalayat

Parent

#1 — Migrate domain event bus from RabbitMQ to Kafka

What to build

Full consumer path: messages on the "course.created" Kafka topic are consumed, deserialized, and delivered to the IncrementCoursesCounterOnCourseCreated application service.

The DomainEventKafkaDeserializer uses the Jackson mix-in to resolve the concrete domain event class from the envelope type field — no reflection, no fromPrimitives(), no classpath scanning.

A CourseCreatedKafkaConsumer infrastructure class with @KafkaListener(topics = "course.created") receives the deserialized event and delegates to the application service via direct constructor injection.

All old consumer infrastructure is deleted: RabbitMQ consumer, auto-starter, reflection-based serializer/deserializer, DomainEventsInformation, DomainEventSubscribersInformation, DomainEventSubscriberInformation.

The IncrementCoursesCounterOnCourseCreated application service is cleaned up: @EventListener annotation removed.

Acceptance criteria

  • End-to-end integration test: publish via KafkaEventBus → consumer deserializes → IncrementCoursesCounterOnCourseCreated.on() is invoked
  • DomainEventKafkaDeserializer unit test proves round-trip (serialize → deserialize → equal event)
  • CourseCreatedKafkaConsumer unit test proves the application service is called with the correct CourseCreatedDomainEvent
  • RabbitMqDomainEventsConsumer, RabbitMqConsumerAutoStarter deleted
  • DomainEventJsonSerializer, DomainEventJsonDeserializer deleted
  • DomainEventsInformation, DomainEventSubscribersInformation, DomainEventSubscriberInformation deleted
  • IncrementCoursesCounterOnCourseCreated has no @EventListener annotation
  • spring-rabbit-test and org.testcontainers:rabbitmq removed from build.gradle

Blocked by

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