# jonashackt/spring-rabbitmq-messaging-microservices architecture

> Architecture diagram of the GitHub repository jonashackt/spring-rabbitmq-messaging-microservices, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jonashackt/spring-rabbitmq-messaging-microservices
- Repository: https://github.com/jonashackt/spring-rabbitmq-messaging-microservices

## Overview

1. **Overall shape**
   This repo is a **multi-module Maven project** built around two Spring Boot microservices that communicate asynchronously through **RabbitMQ**. The core architectural pattern is: one service accepts a request, turns it into a message, RabbitMQ routes it, and the other service consumes it, performs work, then publishes a response message back.

2. **Shared library boundary**
   The `weathershare` module is a **shared Java library**, not a runnable service. It contains the cross-cutting contract between services:
   - message/event types (`EventGetOutlook`, `EventGeneralOutlook`, `EventSimple`)
   - queue names (`Queues`)
   - shared domain model classes (`Weather`, `User`, `Product`, `MethodOfPayment`, `GeneralOutlook`)
   - utility code (`ModelUtil`)
   
   This module is the dependency boundary that keeps both services aligned on message schema and shared DTOs.

3. **`weatherservice` as the entry point**
   `weatherservice` is the **producer-facing microservice**. It exposes an HTTP endpoint layer (`endpoint/WeatherServiceEndpoint`) and has its own messaging package. It receives external requests, converts them into a message, and sends them to RabbitMQ. Its role is to initiate the workflow and later handle the returned result message.

4. **`weatherbackend` as the worker service**
   `weatherbackend` is the **consumer/processor microservice**. It contains:
   - `service/WeatherBackendService` for business orchestration
   - `businesslogic/IncredibleLogic` for the actual computation
   - messaging handlers/senders for RabbitMQ integration
   - a backend healthcheck component
   
   This service consumes the request message, performs the backend logic, and emits the result message back onto the message bus.

5. **Message-driven data flow**
   The main runtime flow is:
   - a request is triggered in `weatherservice`
   - `weatherservice` publishes an event such as `EventGetOutlook` to a RabbitMQ queue
   - one `weatherbackend` instance consumes it
   - `weatherbackend` computes the answer
   - `weatherbackend` publishes `EventGeneralOutlook`
   - `weatherservice` receives the response and logs/uses it
   
   This is the central architecture boundary: **HTTP in one direction, AMQP messaging between services**.

6. **RabbitMQ as the integration hub**
   RabbitMQ is the only required infrastructure component for service-to-service communication. The repository uses the **RabbitMQ management image**, and the README shows it exposed on:
   - AMQP: `5672`
   - management UI: `15672`
   
   In Docker Compose, the backend service is wired to RabbitMQ through the container hostname `rabbitmq`, not `localhost`, which is an important deployment detail.

7. **Scalability model**
   The backend is designed to be **horizontally scalable**. Multiple `weatherbackend` containers can run at the same time, all competing for messages from the same queue. This means load distribution is handled by RabbitMQ queue consumption rather than by direct service-to-service calls.

8. **Runtime packaging and deployment**
   Each microservice has its own `Dockerfile`, and the root repo provides:
   - `docker-compose.yml` for local development
   - `docker-stack.yml` for Swarm deployment
   
   The backend image is built from the Maven-produced JAR in its module. This makes the build pipeline important: the shared library is built first, then backend, then service. The root `pom.xml` controls that module ordering.

9. **Testing strategy**
   The tests are intentionally integration-heavy and mirror the runtime topology:
   - `weatherbackend` tests use **Testcontainers GenericContainer** to start only RabbitMQ
   - `weatherservice` tests use **DockerComposeContainer** to start the real compose setup, including RabbitMQ and the backend service
   
   This shows a clear boundary between isolated service verification and full end-to-end messaging verification.

10. **Health and operability**
    Both services contain dedicated **healthcheck** classes. These are separate from business logic and are part of the operational surface of the system, likely used for container or orchestrator readiness/liveness probing.

11. **Logging and observability**
    Each service has a `logback-spring.xml`, and the README describes optional integration with the **Elastic stack / Logstash** for tracing messages across scaled backend instances. This is not part of the core business flow, but it matters for operating the system when multiple backend replicas are active.

12. **Architectural summary for diagramming**
    A good diagram should show:
    - `weatherservice` on the left as the request initiator
    - RabbitMQ in the center as the message broker
    - one or more `weatherbackend` instances on the right as consumers/processors
    - `weathershare` as a shared code/library dependency beneath both services
    - optional side boxes for Docker Compose/Swarm, tests, and observability tooling
   
    The dominant architectural style is **event-driven microservices with shared contracts and horizontally scalable consumers**.

Main entry points: [`weathershare/src/main/java/de/jonashackt/messaging/EventGetOutlook.java`](https://github.com/jonashackt/spring-rabbitmq-messaging-microservices/blob/master/weathershare/src/main/java/de/jonashackt/messaging/EventGetOutlook.java) (Shared models), [`weatherbackend/src/main/java/de/jonashackt/WeatherBackendApplication.java`](https://github.com/jonashackt/spring-rabbitmq-messaging-microservices/blob/master/weatherbackend/src/main/java/de/jonashackt/WeatherBackendApplication.java) (Backend app), [`weatherservice/src/main/java/de/jonashackt/WeatherServiceApplication.java`](https://github.com/jonashackt/spring-rabbitmq-messaging-microservices/blob/master/weatherservice/src/main/java/de/jonashackt/WeatherServiceApplication.java) (Service app), [`docker-compose.yml`](https://github.com/jonashackt/spring-rabbitmq-messaging-microservices/blob/master/docker-compose.yml) (Compose)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime services"]
  node_backendapp(("Backend app<br/>spring boot"))
  node_backendservice["Backend svc<br/>orchestration"]
  node_logic["Logic"]
  node_bmsgin["Backend msg in<br/>amqp consumer"]
  node_bmsgout["Backend msg out<br/>amqp sender<br/>[MessageSender.java]"]
  node_bconf["Backend mq config<br/>amqp config"]
  node_bhealth(("Backend health<br/>healthcheck"))
  node_serviceapp(("Service app<br/>spring boot"))
  node_endpoint["HTTP endpoint<br/>api layer"]
  node_smsgout["Service msg out<br/>amqp sender<br/>[MessageSender.java]"]
  node_smsgin["Service msg in<br/>amqp consumer"]
  node_sconf["Service mq config<br/>amqp config"]
  node_shealth(("Service health<br/>healthcheck"))
end

subgraph group_shared["Shared contract"]
  node_shareddb["Shared models<br/>contract library"]
  node_modelutil["Model util<br/>[ModelUtil.java]"]
end

subgraph group_ops["Build and ops"]
  node_rootpom["Root POM<br/>maven build<br/>[pom.xml]"]
  node_compose["Compose<br/>local deploy<br/>[docker-compose.yml]"]
  node_stack["Stack<br/>swarm deploy<br/>[docker-stack.yml]"]
  node_backendtest["Backend tests<br/>integration test"]
  node_servicetest["Service tests<br/>integration test"]
  node_backenddocker["Backend image<br/>container build"]
  node_servicedocker["Service image<br/>container build"]
end

node_rootpom -->|"builds first"| node_shareddb
node_rootpom -->|"builds"| node_backendapp
node_rootpom -->|"builds"| node_serviceapp
node_serviceapp -->|"exposes"| node_endpoint
node_endpoint -->|"creates request"| node_smsgout
node_smsgout -->|"uses contracts"| node_shareddb
node_sconf -->|"configures"| node_smsgout
node_smsgin -->|"uses contracts"| node_shareddb
node_smsgin -->|"returns result"| node_endpoint
node_smsgout -->|"publishes via"| node_compose
node_backendapp -->|"starts"| node_backendservice
node_backendservice -->|"delegates"| node_logic
node_backendservice -->|"consumes from"| node_bmsgin
node_bmsgin -->|"uses contracts"| node_shareddb
node_bmsgin -->|"invokes"| node_logic
node_logic -->|"produces response"| node_bmsgout
node_bmsgout -->|"uses contracts"| node_shareddb
node_bmsgout -->|"publishes via"| node_compose
node_backendapp -->|"exposes"| node_bhealth
node_serviceapp -->|"exposes"| node_shealth
node_backenddocker -->|"packages"| node_backendapp
node_servicedocker -->|"packages"| node_serviceapp
node_backendtest -->|"starts broker"| node_compose
node_servicetest -->|"starts stack"| node_compose
node_compose -.->|"mirrors"| node_stack
node_serviceapp -->|"depends on"| node_shareddb
node_backendapp -->|"depends on"| node_shareddb
node_shareddb -->|"includes"| node_modelutil

click node_rootpom "https://github.com/jonashackt/spring-rabbitmq-messaging-microservices/blob/master/pom.xml"
click node_compose "https://github.com/jonashackt/spring-rabbitmq-messaging-microservices/blob/master/docker-compose.yml"
click node_stack "https://github.com/jonashackt/spring-rabbitmq-messaging-microservices/blob/master/docker-stack.yml"
click node_backendapp "https://github.com/jonashackt/spring-rabbitmq-messaging-microservices/blob/master/weatherbackend/src/main/java/de/jonashackt/WeatherBackendApplication.java"
click node_backendservice "https://github.com/jonashackt/spring-rabbitmq-messaging-microservices/blob/master/weatherbackend/src/main/java/de/jonashackt/service/WeatherBackendService.java"
click node_logic "https://github.com/jonashackt/spring-rabbitmq-messaging-microservices/blob/master/weatherbackend/src/main/java/de/jonashackt/businesslogic/IncredibleLogic.java"
click node_bmsgin "https://github.com/jonashackt/spring-rabbitmq-messaging-microservices/blob/master/weatherbackend/src/main/java/de/jonashackt/messaging/MessageHandler.java"
click node_bmsgout "https://github.com/jonashackt/spring-rabbitmq-messaging-microservices/blob/master/weatherbackend/src/main/java/de/jonashackt/messaging/MessageSender.java"
click node_bconf "https://github.com/jonashackt/spring-rabbitmq-messaging-microservices/blob/master/weatherbackend/src/main/java/de/jonashackt/messaging/MessagingConfiguration.java"
click node_bhealth "https://github.com/jonashackt/spring-rabbitmq-messaging-microservices/blob/master/weatherbackend/src/main/java/de/jonashackt/healtcheck/WeatherBackendHealthcheck.java"
click node_serviceapp "https://github.com/jonashackt/spring-rabbitmq-messaging-microservices/blob/master/weatherservice/src/main/java/de/jonashackt/WeatherServiceApplication.java"
click node_endpoint "https://github.com/jonashackt/spring-rabbitmq-messaging-microservices/blob/master/weatherservice/src/main/java/de/jonashackt/endpoint/WeatherServiceEndpoint.java"
click node_smsgout "https://github.com/jonashackt/spring-rabbitmq-messaging-microservices/blob/master/weatherservice/src/main/java/de/jonashackt/messaging/MessageSender.java"
click node_smsgin "https://github.com/jonashackt/spring-rabbitmq-messaging-microservices/blob/master/weatherservice/src/main/java/de/jonashackt/messaging/MessageHandler.java"
click node_sconf "https://github.com/jonashackt/spring-rabbitmq-messaging-microservices/blob/master/weatherservice/src/main/java/de/jonashackt/messaging/MessagingConfiguration.java"
click node_shealth "https://github.com/jonashackt/spring-rabbitmq-messaging-microservices/blob/master/weatherservice/src/main/java/de/jonashackt/healtcheck/WeatherServiceHealthcheck.java"
click node_shareddb "https://github.com/jonashackt/spring-rabbitmq-messaging-microservices/blob/master/weathershare/src/main/java/de/jonashackt/messaging/EventGetOutlook.java"
click node_modelutil "https://github.com/jonashackt/spring-rabbitmq-messaging-microservices/blob/master/weathershare/src/main/java/de/jonashackt/common/ModelUtil.java"
click node_backendtest "https://github.com/jonashackt/spring-rabbitmq-messaging-microservices/blob/master/weatherbackend/src/test/java/de/jonashackt/WeatherBackendSendAndReceiveTest.java"
click node_servicetest "https://github.com/jonashackt/spring-rabbitmq-messaging-microservices/blob/master/weatherservice/src/test/java/de/jonashackt/WeatherServiceSendAndReceiveTest.java"
click node_backenddocker "https://github.com/jonashackt/spring-rabbitmq-messaging-microservices/tree/master/weatherbackend/Dockerfile"
click node_servicedocker "https://github.com/jonashackt/spring-rabbitmq-messaging-microservices/tree/master/weatherservice/Dockerfile"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_backendapp,node_backendservice,node_logic,node_bmsgin,node_bmsgout,node_bconf,node_bhealth,node_serviceapp,node_endpoint,node_smsgout,node_smsgin,node_sconf,node_shealth toneBlue
class node_shareddb,node_modelutil toneAmber
class node_rootpom,node_compose,node_stack,node_backendtest,node_servicetest,node_backenddocker,node_servicedocker toneMint
```

## Components

### Runtime services

Main event-driven application components

- [Backend app](https://github.com/jonashackt/spring-rabbitmq-messaging-microservices/blob/master/weatherbackend/src/main/java/de/jonashackt/WeatherBackendApplication.java): spring boot · Worker service entry point · `weatherbackend/src/main/java/de/jonashackt/WeatherBackendApplication.java`
- [Backend svc](https://github.com/jonashackt/spring-rabbitmq-messaging-microservices/blob/master/weatherbackend/src/main/java/de/jonashackt/service/WeatherBackendService.java): orchestration · Coordinates backend processing · `weatherbackend/src/main/java/de/jonashackt/service/WeatherBackendService.java`
- [Logic](https://github.com/jonashackt/spring-rabbitmq-messaging-microservices/blob/master/weatherbackend/src/main/java/de/jonashackt/businesslogic/IncredibleLogic.java): business logic · Core computation for weather processing · `weatherbackend/src/main/java/de/jonashackt/businesslogic/IncredibleLogic.java`
- [Backend msg in](https://github.com/jonashackt/spring-rabbitmq-messaging-microservices/blob/master/weatherbackend/src/main/java/de/jonashackt/messaging/MessageHandler.java): amqp consumer · Consumes request events · `weatherbackend/src/main/java/de/jonashackt/messaging/MessageHandler.java`
- [Backend msg out](https://github.com/jonashackt/spring-rabbitmq-messaging-microservices/blob/master/weatherbackend/src/main/java/de/jonashackt/messaging/MessageSender.java): amqp sender · Publishes response events · `weatherbackend/src/main/java/de/jonashackt/messaging/MessageSender.java`
- [Backend mq config](https://github.com/jonashackt/spring-rabbitmq-messaging-microservices/blob/master/weatherbackend/src/main/java/de/jonashackt/messaging/MessagingConfiguration.java): amqp config · RabbitMQ wiring for backend · `weatherbackend/src/main/java/de/jonashackt/messaging/MessagingConfiguration.java`
- [Backend health](https://github.com/jonashackt/spring-rabbitmq-messaging-microservices/blob/master/weatherbackend/src/main/java/de/jonashackt/healtcheck/WeatherBackendHealthcheck.java): healthcheck · Operational probe endpoint/component · `weatherbackend/src/main/java/de/jonashackt/healtcheck/WeatherBackendHealthcheck.java`
- [Service app](https://github.com/jonashackt/spring-rabbitmq-messaging-microservices/blob/master/weatherservice/src/main/java/de/jonashackt/WeatherServiceApplication.java): spring boot · Producer-facing service entry point · `weatherservice/src/main/java/de/jonashackt/WeatherServiceApplication.java`
- [HTTP endpoint](https://github.com/jonashackt/spring-rabbitmq-messaging-microservices/blob/master/weatherservice/src/main/java/de/jonashackt/endpoint/WeatherServiceEndpoint.java): api layer · Receives external requests · `weatherservice/src/main/java/de/jonashackt/endpoint/WeatherServiceEndpoint.java`
- [Service msg out](https://github.com/jonashackt/spring-rabbitmq-messaging-microservices/blob/master/weatherservice/src/main/java/de/jonashackt/messaging/MessageSender.java): amqp sender · Turns HTTP requests into request events · `weatherservice/src/main/java/de/jonashackt/messaging/MessageSender.java`
- [Service msg in](https://github.com/jonashackt/spring-rabbitmq-messaging-microservices/blob/master/weatherservice/src/main/java/de/jonashackt/messaging/MessageHandler.java): amqp consumer · Receives backend responses · `weatherservice/src/main/java/de/jonashackt/messaging/MessageHandler.java`
- [Service mq config](https://github.com/jonashackt/spring-rabbitmq-messaging-microservices/blob/master/weatherservice/src/main/java/de/jonashackt/messaging/MessagingConfiguration.java): amqp config · RabbitMQ wiring for service · `weatherservice/src/main/java/de/jonashackt/messaging/MessagingConfiguration.java`
- [Service health](https://github.com/jonashackt/spring-rabbitmq-messaging-microservices/blob/master/weatherservice/src/main/java/de/jonashackt/healtcheck/WeatherServiceHealthcheck.java): healthcheck · Operational probe component · `weatherservice/src/main/java/de/jonashackt/healtcheck/WeatherServiceHealthcheck.java`

### Shared contract

Cross-service message and model types

- [Shared models](https://github.com/jonashackt/spring-rabbitmq-messaging-microservices/blob/master/weathershare/src/main/java/de/jonashackt/messaging/EventGetOutlook.java): contract library · Events, queues, and DTOs shared by both services · `weathershare/src/main/java/de/jonashackt/messaging/EventGetOutlook.java`
- [Model util](https://github.com/jonashackt/spring-rabbitmq-messaging-microservices/blob/master/weathershare/src/main/java/de/jonashackt/common/ModelUtil.java): utility · Shared helper for model handling · `weathershare/src/main/java/de/jonashackt/common/ModelUtil.java`

### Build and ops

Packaging, deployment, and observability

- [Root POM](https://github.com/jonashackt/spring-rabbitmq-messaging-microservices/blob/master/pom.xml): maven build · Multi-module build and module order · `pom.xml`
- [Compose](https://github.com/jonashackt/spring-rabbitmq-messaging-microservices/blob/master/docker-compose.yml): local deploy · Local RabbitMQ plus service topology · `docker-compose.yml`
- [Stack](https://github.com/jonashackt/spring-rabbitmq-messaging-microservices/blob/master/docker-stack.yml): swarm deploy · Swarm deployment definition · `docker-stack.yml`
- [Backend tests](https://github.com/jonashackt/spring-rabbitmq-messaging-microservices/blob/master/weatherbackend/src/test/java/de/jonashackt/WeatherBackendSendAndReceiveTest.java): integration test · RabbitMQ-focused send/receive verification · `weatherbackend/src/test/java/de/jonashackt/WeatherBackendSendAndReceiveTest.java`
- [Service tests](https://github.com/jonashackt/spring-rabbitmq-messaging-microservices/blob/master/weatherservice/src/test/java/de/jonashackt/WeatherServiceSendAndReceiveTest.java): integration test · Compose-based end-to-end verification · `weatherservice/src/test/java/de/jonashackt/WeatherServiceSendAndReceiveTest.java`
- [Backend image](https://github.com/jonashackt/spring-rabbitmq-messaging-microservices/tree/master/weatherbackend/Dockerfile): container build · Container packaging for backend service · `weatherbackend/Dockerfile`
- [Service image](https://github.com/jonashackt/spring-rabbitmq-messaging-microservices/tree/master/weatherservice/Dockerfile): container build · Container packaging for service · `weatherservice/Dockerfile`

## Connections

- Root POM → Shared models: builds first · Shared module is compiled before services
- Root POM → Backend app: builds · Maven builds backend module
- Root POM → Service app: builds · Maven builds service module
- Service app → HTTP endpoint: exposes · HTTP entry point accepts external requests
- HTTP endpoint → Service msg out: creates request · Request is converted into an AMQP message
- Service msg out → Shared models: uses contracts · Shares event and queue types
- Service mq config → Service msg out: configures · Wires messaging behavior
- Service msg in → Shared models: uses contracts · Consumes shared response event types
- Service msg in → HTTP endpoint: returns result · Response is received and used by service side
- Service msg out → Compose: publishes via · Messages go through RabbitMQ in local compose
- Backend app → Backend svc: starts · Application boots backend orchestration
- Backend svc → Logic: delegates · Business work is handled by core logic
- Backend svc → Backend msg in: consumes from · Backend listens for request events
- Backend msg in → Shared models: uses contracts · Request event types come from shared library
- Backend msg in → Logic: invokes · Consumed message triggers computation
- Logic → Backend msg out: produces response · Computed result is sent back to broker
- Backend msg out → Shared models: uses contracts · Response event types come from shared library
- Backend msg out → Compose: publishes via · Backend responds through RabbitMQ
- Backend app → Backend health: exposes · Backend includes operational health surface
- Service app → Service health: exposes · Service includes operational health surface
- Backend image → Backend app: packages · Backend Docker image wraps built application
- Service image → Service app: packages · Service Docker image wraps built application
- Backend tests → Compose: starts broker · Backend tests bootstrap RabbitMQ only
- Service tests → Compose: starts stack · Service tests run against real compose topology
- Compose → Stack: mirrors · Local compose and swarm stack represent same topology
- Service app → Shared models: depends on · Service uses shared message and model types
- Backend app → Shared models: depends on · Backend uses shared message and model types
- Shared models → Model util: includes · Shared library contains common utility support
