Skip to content

[REFACTOR] Extract Kafka configuration into a dedicated KafkaModule #222

Closed

Description

@aniebietafia

Problem

Kafka configurations are currently scattered across multiple disjointed packages:

  • brokers/kafka/config/ (contains general Kafka consumer, producer, and topic configs)
  • payment/common/events/ (contains payment-specific Kafka configurations)
  • coupon/kafka/ (contains coupon bulk generation consumers)
  • ocrprocessing/events/ (contains OCR message listeners)
  • elasticsearch/events/ (contains ES index consumers)
  • pushnotification/kafka/ (contains notification message consumers)

This fragmentation makes it hard to manage shared serialization logic, properties, error recovery protocols, and performance tuning configurations. Changes to broker addresses or global serialization properties require updates in multiple packages.

Proposed Solution

Create a central top-level module com.xtraction.api.shared.kafka (or com.xtraction.api.brokers.kafka as a single source of truth) containing all Kafka core infrastructure configs. Feature modules should only contain their listener/producer service logic and should import or reference the core configurations.

User Stories

  • As a DevOps engineer, I want all Kafka infrastructure configurations to live in one package so that I can easily configure clustering, security credentials, and performance parameters in a single place.
  • As a developer, I want to write new Kafka producers and consumers without duplicating boilerplate configuration templates.

Acceptance Criteria

  • Core Kafka beans (producer factories, container factories, common templates, and error handlers) are consolidated under src/main/java/com/xtraction/api/shared/kafka/config/.
  • Duplicate configurations are removed from PaymentKafkaConsumerConfig.java.
  • Feature modules depend on the core config module and do not define their own ConsumerFactory or listener factory unless strictly required for custom serialization formats.

Tasks

  • Create package com.xtraction.api.shared.kafka.config.
  • Migrate KafkaConsumerConfig.java and KafkaProducerConfig.java to the shared package.
  • Update import statements across all event listeners.

Activity

  1. added
    bug
    enhancement
    on Jun 21, 2026
  2. aniebietafia commented on Jun 21, 2026

    @aniebietafia
    ContributorAuthor

    Hi @coclock,

    Thanks for your interest to work on this issue! However, please note that this repository is a Java / Spring Boot / Maven project, not a TypeScript or JavaScript project.

    Because of this:

    We do not have a package.json file or any npm dependencies.
    The issue we are solving involves refactoring Java classes and package structures under src/main/java/com/xtraction/api/... (specifically consolidating Spring Kafka beans and updating import statements across event listener classes).
    To help get you started on the right path, here is what a revised approach for this project should look like:

    • Locate the Java configs: Identify the core Kafka files in com.xtraction.api.brokers.kafka.config.
      Refactor & Migrate: Move these files to the new target package com.xtraction.api.shared.kafka.config and consolidate duplicate configurations from PaymentKafkaConsumerConfig.java.
    • Update imports: Update the import statements in all listener classes (e.g., UserEventListener.java, PaymentEventListener.java, etc.) to point to the new package path.
    • Build & Verify: Clean and compile the project using Maven: ./mvnw clean test-compile (or mvnw.cmd on Windows) to verify the changes compile cleanly. Run ./mvnw test to ensure tests pass.

    Please confirm from the docs for any relevant information that you might need.

    Let me know if you have any questions about the Java setup or running Maven!"

  3. self-assigned this
    on Jul 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

apibugcidependenciesdockeremailenhancementocrpaymentperformancesecurity

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions