API Documentation:
View Complete API Collection in Postman
A production-ready Spring Boot application demonstrating advanced concurrency patterns and thread-safe operations in an e-commerce domain. This project implements enterprise-grade concurrent programming techniques including optimistic and pessimistic locking, asynchronous processing, producer-consumer patterns, and thread-safe CRUD operations.
- Thread-Safe CRUD Operations utilizing ReentrantReadWriteLocks for optimal performance
- Database Locking Strategies with both optimistic and pessimistic locking mechanisms
- Asynchronous Processing leveraging CompletableFuture for non-blocking operations
- Producer-Consumer Architecture for scalable order processing workflows
- Concurrent Caching Layer implemented with ConcurrentHashMap
- Batch Processing Framework with configurable thread pool management
- Real-time System Monitoring and performance analytics
- Integrated Load Testing for performance validation
- Java 17
- Spring Boot 3.2.0
- Spring Data JPA
- H2 Database (In-memory)
- Spring Boot Actuator
- Maven 3.6+
- Java Development Kit 17 or higher
- Apache Maven 3.6 or higher
- Git version control system
git clone https://github.com/parameshn/concurrent-E-commerce-app.git
cd concurrent-E-commerce-appmvn clean install
mvn spring-boot:runThe application will be accessible at http://localhost:8080
- URL:
http://localhost:8080/h2-console - JDBC URL:
jdbc:h2:mem:ecommerce - Username:
sa - Password: (empty)
# Create a new product
curl -X POST http://localhost:8080/api/products \
-H "Content-Type: application/json" \
-d '{
"name": "Gaming Laptop",
"description": "High-performance gaming laptop",
"price": 1299.99,
"stockQuantity": 25,
"category": "Electronics"
}'# Execute concurrent read operations
curl -X POST http://localhost:8080/api/load-test/concurrent-reads/10/100
# Test concurrent update operations
curl -X POST http://localhost:8080/api/load-test/concurrent-updates/5/50# Retrieve system analytics
curl http://localhost:8080/api/monitoring/analytics
# Monitor thread pool statistics
curl http://localhost:8080/api/monitoring/thread-info
# Check memory utilization
curl http://localhost:8080/api/monitoring/memory-info- Read-Write Locking - Optimized concurrent read access with exclusive write operations
- Optimistic Locking - JPA-based version control with automatic retry mechanisms
- Pessimistic Locking - Database-level locking for critical transaction handling
- StampedLock Implementation - High-performance optimistic read operations for analytics
- Producer-Consumer Pattern - Asynchronous order processing with blocking queue implementation
- Thread Pool Management - Custom executor services for different operational contexts
- ProductService - Thread-safe product lifecycle management with integrated caching
- OrderService - Asynchronous order processing with queue-based workflow management
- AnalyticsService - Real-time performance metrics with StampedLock optimization
- CacheService - Concurrent caching implementation with automatic expiration
- BatchProcessingService - Parallel batch operation execution framework
| Endpoint | Description |
|---|---|
/api/monitoring/analytics |
Comprehensive system analytics and metrics |
/api/monitoring/thread-info |
Thread pool utilization statistics |
/api/monitoring/memory-info |
JVM memory usage and allocation details |
/api/monitoring/cache/size |
Cache performance and utilization metrics |
/api/orders/queue/size |
Order processing queue status |
Built-in load testing endpoints for performance validation:
- Concurrent Read Testing:
/api/load-test/concurrent-reads/{threads}/{iterations} - Concurrent Update Testing:
/api/load-test/concurrent-updates/{threads}/{iterations} - Batch Operation Testing:
/api/load-test/batch-operations/{count}
Application configuration parameters in application.yml:
spring:
task:
execution:
pool:
core-size: 8
max-size: 16
queue-capacity: 500
scheduling:
pool:
size: 4Port Conflict (8080)
# Modify application.yml
server:
port: 8081Memory Constraints During Load Testing
export MAVEN_OPTS="-Xmx2g -XX:+UseG1GC"
mvn spring-boot:runThread Pool Saturation
- Monitor thread utilization via
/api/monitoring/thread-info - Adjust thread pool configuration based on system capacity
The application provides comprehensive monitoring for:
- Thread pool utilization and performance
- Cache hit ratios and efficiency metrics
- Operation execution counters
- JVM memory usage patterns
- Queue processing statistics
- Response time analytics
We welcome contributions to enhance the project's functionality and performance.
- Fork the repository
- Create a feature branch (
git checkout -b feature/enhancement-name) - Implement changes with appropriate test coverage
- Commit changes (
git commit -m 'Add feature: enhancement description') - Push to the branch (
git push origin feature/enhancement-name) - Submit a Pull Request with detailed description
This project is licensed under the MIT License. See the LICENSE file for complete license terms.
For comprehensive API documentation with request/response examples, please refer to the Postman Collection