A practical implementation of asynchronous communication using Spring Boot and RabbitMQ. The system processes orders without blocking the client request using event-driven architecture.
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.
Client ---> Order Service ---> returns "Order Received" immediately | | publishes OrderPlaced event v Consumer (simulating Payment & Notification) processes order asynchronously
- Java 21
- Spring Boot
- RabbitMQ
- Maven
- REST API
RabbitMQ requires Erlang to be installed first.
- Go to the official Erlang website: https://www.erlang.org/downloads
- Download the latest Windows installer.
- Install it normally.
- Set environment variable:
- Variable Name: ERLANG_HOME
- Value:
C:\Program Files\Erlang OTP\erl-XX.X
- Open CMD and verify:
If Erlang shell opens successfully → Installation is correct.
erl
-
Go to official RabbitMQ website: https://www.rabbitmq.com/docs/download
-
Download the Windows installer.
-
Install normally.
-
Add RabbitMQ sbin folder to PATH:
Example:
C:\Program Files\RabbitMQ Server\rabbitmq_server-3.xx.x\sbin
- Open CMD as Administrator:
rabbitmq-plugins enable rabbitmq_management - Restart the service:
net stop RabbitMQ net start RabbitMQ
- Open your browser:
http://localhost:15672
- Default credentials:
If the dashboard appears successfully → RabbitMQ is ready 🎉
username: guest password: guest
- Start RabbitMQ
- Run your Spring Boot application
- 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{...}
- Response:
- Asynchronous message publishing using RabbitMQ
- Event-driven concept
- Immediate response to client
- How consumers process messages independently