A REST service built with Spring Boot and RabbitMQ for message consumption and publishing.
- ✅ REST API endpoints for health checks and message handling
- ✅ RabbitMQ integration for message publishing and consumption
- ✅ Java 25
- ✅ Maven as package manager
- ✅ JUnit 5 for unit testing
- ✅ Wiremock for integration testing
- ✅ Spring Boot Actuator for health monitoring
- ✅ OpenAPI 3.0 contracts for REST endpoints and RabbitMQ messages
- Java 25 or higher
- Maven 3.9+
- RabbitMQ server (for running the application)
OpenAPI specifications are available in the .contracts/ directory:
- rest-api.yaml - REST API endpoints specification
- rabbitmq-messages.yaml - RabbitMQ message payload contracts
See .contracts/README.md for more details on using these contracts.
.contracts/
├── rest-api.yaml # OpenAPI spec for REST endpoints
├── rabbitmq-messages.yaml # RabbitMQ message contracts
└── README.md # Contracts documentation
src/
├── main/
│ ├── java/com/openai/generated/javaservice/
│ │ ├── JavaServiceApplication.java # Main application class
│ │ ├── config/
│ │ │ └── RabbitMQConfig.java # RabbitMQ configuration
│ │ ├── controller/
│ │ │ └── MessageController.java # REST API endpoints
│ │ ├── messaging/
│ │ │ ├── MessagePublisher.java # RabbitMQ publisher
│ │ │ └── MessageListener.java # RabbitMQ listener
│ │ └── model/
│ │ └── Message.java # Message model
│ └── resources/
│ └── application.properties # Application configuration
└── test/
├── java/com/openai/generated/javaservice/
│ ├── controller/
│ │ └── MessageControllerTest.java # Controller unit tests
│ ├── messaging/
│ │ ├── MessagePublisherTest.java # Publisher unit tests
│ │ └── MessageListenerTest.java # Listener unit tests
│ ├── model/
│ │ └── MessageTest.java # Model unit tests
│ └── MessageControllerIntegrationTest.java # Integration tests with Wiremock
└── resources/
└── application-test.properties # Test configuration
This project is configured to use Java 25. Note that Spring Boot 3.4.1 has partial support for Java 25:
- Compilation: Works perfectly with Java 25
- Runtime: Runs successfully with Java 25
- Testing: The
-Dspring.classformat.ignore=truesystem property is configured in Maven to handle Java 25 class files
Some Spring Boot integration tests may have limitations due to ASM ClassReader not fully supporting Java 25 class file format (version 69). The project uses RabbitOperations interface instead of concrete RabbitTemplate for better mockability in tests.
mvn clean installmvn testmvn verify- Ensure RabbitMQ is running on localhost:5672
- Run the application:
mvn spring-boot:runThe application will start on port 8080.
GET /api/health
Returns the health status of the application.
POST /api/messages
Content-Type: application/json
{
"content": "Your message content"
}
Publishes a message to RabbitMQ and returns the message ID.
GET /api/messages/test
Returns a sample test message.
Edit src/main/resources/application.properties to configure:
- Server port
- RabbitMQ connection settings
- Logging levels
- Actuator endpoints
- Java 25 - Programming language
- Spring Boot 3.4.1 - Application framework
- Spring AMQP - RabbitMQ integration
- Maven - Build and dependency management
- JUnit 5 - Unit testing framework
- Mockito - Mocking framework for tests
- Wiremock - HTTP mocking for integration tests
- Spring Boot Actuator - Production-ready features
See LICENSE file for details.