y0ncha/eda-producer

By y0ncha

Updated 6 months ago

A small event-driven order system with services that communicate through a message broker.

Image
Message queues
0

1.9K

y0ncha/eda-producer repository overview

Overview

This project is a small event-driven order pipeline built around two services that communicate through a message broker (RabbitMQ or Kafka).

Components
  • Producer (Order API)

    • Exposes a REST endpoint: POST /create-order
    • Validates the request payload and builds an order event
    • Serializes the event as JSON
    • Publishes the event to the broker (asynchronously decoupling API from processing)
  • Message Broker (RabbitMQ / Kafka)

    • Acts as the transport layer between services
    • Buffers events so the consumer can process at its own pace
    • Decouples availability and scaling (producer doesn’t need direct access to consumer)
  • Consumer (Order Processor + Query API)

    • Subscribes to order events from the broker
    • Enriches the order by adding:
      • shippingCost = 0.02 * totalAmount
    • Stores enriched orders in memory
    • Exposes a REST endpoint: GET /order-details?orderId=...
Data flow
  1. Client calls POST /create-order on the Producer.
  2. Producer validates input, serializes the order as JSON, and publishes an order event to the broker.
  3. Consumer receives the event, enriches the order (adds shipping cost), and stores it in memory.
  4. Client calls GET /order-details?orderId=... on the Consumer to fetch the enriched order.
Error handling (high level)
  • Producer

    • Returns a clear HTTP error for invalid input (e.g., missing orderId, invalid numOfItems)
    • Treats broker unavailability as an operational failure (publish fails -> request fails or retries, depending on configuration)
  • Consumer

    • Handles transient broker issues by retrying/reconnecting
    • If an incoming message is malformed, it is rejected/logged (and not stored)
Why event-driven here?
  • Removes direct coupling between API and processing logic
  • Allows independent scaling (more consumers without changing producer)
  • Improves resilience by buffering events in the broker

Tag summary

Content type

Image

Digest

sha256:c5455a84e

Size

140 MB

Last updated

6 months ago

docker pull y0ncha/eda-producer:2.0.0