Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

10 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

openai-generated-java-service

A REST service built with Spring Boot and RabbitMQ for message consumption and publishing.

Features

  • ✅ 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

Prerequisites

  • Java 25 or higher
  • Maven 3.9+
  • RabbitMQ server (for running the application)

API Contracts

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.

Project Structure

.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

Java 25 Support

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=true system 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.

Building the Project

mvn clean install

Running Unit Tests

mvn test

Running Integration Tests

mvn verify

Running the Application

  1. Ensure RabbitMQ is running on localhost:5672
  2. Run the application:
mvn spring-boot:run

The application will start on port 8080.

API Endpoints

Health Check

GET /api/health

Returns the health status of the application.

Send Message

POST /api/messages
Content-Type: application/json

{
  "content": "Your message content"
}

Publishes a message to RabbitMQ and returns the message ID.

Get Test Message

GET /api/messages/test

Returns a sample test message.

Configuration

Edit src/main/resources/application.properties to configure:

  • Server port
  • RabbitMQ connection settings
  • Logging levels
  • Actuator endpoints

Technologies Used

  • 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

License

See LICENSE file for details.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages