Skip to content

A practical demo of asynchronous communication using Spring Boot and RabbitMQ. Orders are processed without blocking the client request, demonstrating event-driven architecture.

License

Notifications You must be signed in to change notification settings

ayaHathout/SpringBoot-RabbitMQ-Order-System

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 

Repository files navigation

SpringBoot-RabbitMQ-Order-System

A practical implementation of asynchronous communication using Spring Boot and RabbitMQ. The system processes orders without blocking the client request using event-driven architecture.


📌 Overview

This project demonstrates a basic event-driven flow using Spring Boot and RabbitMQ.

  • Customers can create orders using a REST API.
  • Orders are immediately sent to RabbitMQ as messages (events).
  • A consumer reads the messages asynchronously and processes them.
  • Client receives an immediate response without waiting for processing.

This demo shows the core idea of asynchronous communication and event-driven architecture before scaling to multiple microservices like Payment or Notification services.


🏗 Flow

Client ---> Order Service ---> returns "Order Received" immediately | | publishes OrderPlaced event v Consumer (simulating Payment & Notification) processes order asynchronously


🛠 Tech Stack

  • Java 21
  • Spring Boot
  • RabbitMQ
  • Maven
  • REST API

🐰 Installing RabbitMQ For Windows (Step-by-Step Guide)

RabbitMQ requires Erlang to be installed first.

1️⃣ Install Erlang

  1. Go to the official Erlang website: https://www.erlang.org/downloads
  2. Download the latest Windows installer.
  3. Install it normally.
  4. Set environment variable:
    • Variable Name: ERLANG_HOME
    • Value:
      C:\Program Files\Erlang OTP\erl-XX.X
  5. Open CMD and verify:
    erl
    If Erlang shell opens successfully → Installation is correct.

2️⃣ Install RabbitMQ

  1. Go to official RabbitMQ website: https://www.rabbitmq.com/docs/download

  2. Download the Windows installer.

  3. Install normally.

  4. Add RabbitMQ sbin folder to PATH:

    Example:

    C:\Program Files\RabbitMQ Server\rabbitmq_server-3.xx.x\sbin

3️⃣ Enable Management Plugin

  1. Open CMD as Administrator:
    rabbitmq-plugins enable rabbitmq_management
  2. Restart the service:
    net stop RabbitMQ
    net start RabbitMQ

4️⃣ Access RabbitMQ Dashboard

  1. Open your browser:
    http://localhost:15672
  2. Default credentials:
     username: guest
     password: guest
    If the dashboard appears successfully → RabbitMQ is ready 🎉

🚀 Running the Demo

  1. Start RabbitMQ
  2. Run your Spring Boot application
  3. Test endpoint:
    POST /orders
    Content-Type: application/json
     
    {
       "productName": "Book",
       "productPrice": "20",
       "productQuantity": "2"
    }
    • Response:
      {
         "order": {
            "productName": "Book",
            "productPrice": "20",
            "productQuantity": "2"
         },
         "orderStatus": "Placed",
         "message": "Your order has been placed successfully"
      }
    • Consumer prints the message asynchronously:
      Consumer received OrderResponseDTO{...}

🔥 What This Demo Shows

  • Asynchronous message publishing using RabbitMQ
  • Event-driven concept
  • Immediate response to client
  • How consumers process messages independently

About

A practical demo of asynchronous communication using Spring Boot and RabbitMQ. Orders are processed without blocking the client request, demonstrating event-driven architecture.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages