2774ce079304a3db4778674c9b1d12e0a9522525
EventProducer
Spring Boot starter application that publishes JSON events to RabbitMQ topic exchanges (no stream plugins required). The project uses Spring Boot 4.0.2 with Java 21.
Prerequisites
- JDK 21 or newer
- Locally running RabbitMQ broker reachable at the host/port set in
src/main/resources/application.yml
Useful Commands
./gradlew bootRun— start the application./gradlew test— run the test suite./gradlew build— create an executable jar inbuild/libs
Configuration
- RabbitMQ connection + exchange name are defined in
application.yml. Override via the exposed environment variables below or your own profile files. - All messages are sent to the configured topic exchange; routing keys come from the request path.
| Environment Variable | Default | Description |
|---|---|---|
RABBITMQ_HOST |
mit.loc |
Broker hostname |
RABBITMQ_PORT |
5672 |
Broker port |
RABBITMQ_USERNAME |
producer |
Username for broker auth |
RABBITMQ_PASSWORD |
producer |
Password for broker auth |
RABBITMQ_EXCHANGE |
dev.insurance.health.request |
Topic exchange the producer targets |
RABBITMQ_QUEUE |
dev.insurance.health.request.queue |
Queue bound to the topic exchange |
RABBITMQ_ROUTING_KEY |
dev.insurance.health.request.route |
Default routing key for /api/events/messages |
Sending Events
curl --request POST http://localhost:8080/api/events/orders.created \
--header 'Content-Type: application/json' \
--data '{
"eventType": "order-created",
"payload": {
"orderId": "12345",
"total": 42.50
}
}'
Sending Simple Messages
curl --request POST http://localhost:8080/api/events/messages \
--header 'Content-Type: application/json' \
--data '{
"message": "hello topic queue"
}'
API Docs
- OpenAPI JSON:
http://localhost:8080/api-docs - Swagger UI:
http://localhost:8080/swagger-ui
If you ever remove the Gradle wrapper, run
gradle wrapperonce (requires Gradle locally) so that subsequent builds can use./gradlew.
Description
Languages
Java
100%