Skip to content

Add Spring Cloud Command Routing sample - #466

Closed
abuijze wants to merge 1 commit into
mainfrom
feature/spring-cloud-command-routing
Closed

abuijze wants to merge 1 commit into
mainfrom
feature/spring-cloud-command-routing

Conversation

@abuijze

@abuijze abuijze commented Sep 27, 2026

Copy link
Copy Markdown

Builds against Axoniq Framework 5.4.0-SNAPSHOT, which introduces the Spring Cloud connector (AxonIQ/axoniq-framework#399). On Spring Boot 4 it also needs AxonIQ/AxonFramework#5084. Once both are released, the version moves to the release.

Adds the Spring Cloud Command Routing sample, showing how the Axoniq Framework Spring Cloud connector routes commands between the instances of an application, without Axon Server.

What it does

Every instance runs the same application, registers with Consul, and handles one command, SayHello, replying with the id of the instance that handled it:

GET /hello/alice  →  Hello alice, from spring-cloud-command-routing-8082

SayHello declares @Command(routingKey = "name"). Running several instances on different ports shows that:

  • every greeting for the same name is handled by the same instance, whichever instance received the request
  • different names are spread over the instances
  • when an instance stops, only the names it handled move to another instance

The application needs no Axon-specific configuration: axoniq-springcloud, a Spring Cloud discovery implementation (spring-cloud-starter-consul-discovery) and a servlet web stack (spring-boot-starter-web) are enough. A docker-compose.yml starts Consul, and requests.http sends greetings through different instances.

Worth a reviewer's attention

  • Two Spring stacks. The sample builds against Spring Boot 4 with Spring Cloud 2025.1 by default, and against Spring Boot 3.5 with Spring Cloud 2025.0 with the spring-boot-3 profile.
  • Jackson on Spring Boot 3.5. Axon Framework uses Jackson 3, which needs newer Jackson 2 annotations than Spring Boot 3.5 manages, so the spring-boot-3 profile imports jackson-bom 2.22.2.
  • No health check. The sample has no actuator, so it registers with Consul without a health check.

Verification

  • Three instances on Spring Boot 4.1 / Spring Cloud 2025.1, and three on Spring Boot 3.5 / Spring Cloud 2025.0, each route every name to the same instance from every instance, and spread 40 names over all three.
  • After stopping one instance, only the names it handled move to the remaining instances.
  • The instructions in the README, running each instance with PORT=<port> ../mvnw spring-boot:run, start the application as described.

Shows the Axoniq Framework Spring Cloud connector routing commands
between instances of one application through Consul discovery, on
Spring Boot 4 by default and on Spring Boot 3.5 with a profile.

@jangalinski jangalinski left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice one

@jangalinski
jangalinski marked this pull request as ready for review September 29, 2026 22:55
@jangalinski
jangalinski requested a review from smcvb as a code owner September 29, 2026 22:55
@smcvb

smcvb commented Oct 6, 2026

Copy link
Copy Markdown
Collaborator

Closing this PR in favor of AxonIQ/AxonFramework#5095. When possible, having the examples in Axon Framework itself is easier for the team to maintain.

@smcvb smcvb closed this Oct 6, 2026
@smcvb
smcvb deleted the feature/spring-cloud-command-routing branch October 6, 2026 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants