π’ This project is now fully documented in English.
For the original version in Spanish, switch to themainbranch.
A reactive event-driven microservice built with Spring Boot 3, Spring WebFlux, Apache Kafka, Redis, and MongoDB.
The service consumes order events from Kafka, enriches them with customer and product information obtained from external APIs, applies resilience patterns, and persists the resulting data in MongoDB.
This project demonstrates modern backend engineering practices including reactive programming, distributed caching, event-driven architecture, fault tolerance, and scalable asynchronous processing.
- Project Overview
- Architecture Overview
- Architecture Highlights
- Key Features
- Technology Stack
- Project Structure
- Setup
- Run the Project
- Sample Payload
- Testing
- Scalability and Optimization
- Author
The application consumes order events from Kafka and processes them through a reactive pipeline.
During processing:
- Orders are received from a Kafka topic.
- Customer information is retrieved from an external API.
- Product information is retrieved from an external API.
- Redis is used for caching and distributed locking.
- Orders are validated and enriched.
- Final orders are persisted in MongoDB.
- Fault tolerance mechanisms protect external integrations.
The architecture is designed to support high-throughput workloads while maintaining resilience and scalability.
flowchart LR
Kafka["Kafka Topic"]
Consumer["Kafka Order Consumer"]
Processor["Order Processing Service"]
Redis["Redis Cache & Distributed Locks"]
CustomerAPI["Customer API (Go)"]
ProductAPI["Product API (Go)"]
MongoService["Order Storage Service"]
MongoDB[("MongoDB")]
Kafka --> Consumer
Consumer --> Processor
Processor --> Redis
Processor --> CustomerAPI
Processor --> ProductAPI
Processor --> MongoService
MongoService --> MongoDB
- Event-driven architecture using Apache Kafka.
- Fully reactive processing pipeline powered by Spring WebFlux.
- External service enrichment using customer and product APIs.
- Redis used for caching and distributed locking.
- Fault tolerance implemented with Retry and Circuit Breaker patterns.
- MongoDB persistence with optimized indexing strategy.
- Non-blocking asynchronous processing.
- Designed for scalability and high-throughput workloads.
- Reactive Kafka consumer.
- Order enrichment using external services.
- Redis cache integration.
- Distributed locking support.
- MongoDB persistence.
- Retry and Circuit Breaker with Resilience4j.
- Reactive programming with Project Reactor.
- Validation and business rules enforcement.
- Event-driven processing model.
- Java 21
- Spring Boot 3.x
- Spring WebFlux
- Project Reactor
- Apache Kafka
- MongoDB
- Redis
- Resilience4j
- Reactor Retry
- Go APIs (Customer Service & Product Service)
- JUnit 5
- Mockito
src/main/java
β
βββ config
βββ consumer
βββ service
βββ repository
βββ model
βββ dto
βββ mapper
βββ exception
βββ util
- Java 21+
- Maven
- Docker
- MongoDB
- Redis
- Apache Kafka
- Go
Update the application configuration:
spring.kafka.bootstrap-servers=localhost:9092
spring.data.mongodb.uri=mongodb://localhost:27017/pedidosDB
spring.data.redis.host=localhost
spring.data.redis.port=6379Start:
- Kafka
- Redis
- MongoDB
From the /go-api directory:
go run main.goAvailable endpoints:
GET /product
GET /customer
mvn spring-boot:run{
"orderId": "order-100",
"customerId": "Freyder-111",
"products": [
{
"productId": "product-100",
"name": "Iphone",
"price": 2000
}
]
}Run all tests:
mvn testCovered scenarios:
- Successful order processing.
- Inactive customer.
- Product not found.
- Redis lock handling.
- External service failures.
- Retry execution.
- Circuit breaker activation.
- Indexes on
orderId - Indexes on
customerId
- Cache layer to reduce external API calls.
- Distributed locks to prevent duplicate processing.
- Horizontal consumer scalability.
- Asynchronous event processing.
- Retry policies.
- Circuit Breaker pattern.
- Graceful failure handling.
- Event-Driven Architecture.
- Reactive Programming.
- Distributed Systems Design.
- Integration with External Services.
- Fault Tolerant Applications.
- Redis Caching Strategies.
- Kafka Message Processing.
- Modern Cloud-Native Backend Development.
Freyder Otalvaro
Senior Software Engineer | Java | AWS | Distributed Systems
- GitHub: https://github.com/freyderdev
- LinkedIn: https://www.linkedin.com/in/freyder-otalvaro-70484b73/
- Location: Colombia π¨π΄