Code Samples

Where you can find different code examples for Axon Framework

Complete Projects

AxonIQ hotel demo

It's the implementation of the example used in this blog post:

Giftcard Demo

This Axon Framework demo application focuses on a simple giftcard domain designed to show various framework aspects. The app can be run in various modes, using Spring-boot Profiles: by selecting a specific profile, only the corresponding parts of the app will be active. Select none, and the default behaviour is activated, which activates everything. This way, you can experiment with Axon in a (structured) monolith as well as in micro-services.

Running Axon Server

The files in this repo accompany the "Running Axon Server" Blog series.

  1. 1-local contains scripts and configuration files for running Axon Server as a local process.
  2. 2-docker contains the files for "pure" Docker.
  3. 3-k8s is all about Kubernetes deployments.
  4. The ee-image directory (under "2-docker") contains the files for making an Axon Server EE Docker image.
  5. Finally, the Axon Server QuickTest directory provides a small app to verify that Axon Server is up and running.
Axon Observability Demo

Please watch the full webinar that explains all parts of this demo project.

Monitoring stack includes Prometheus, Grafana & Alert manager. Metrics from Axon Framework and Axon Server will be scraped by Prometheus.

Maven Modules

Axon Spring template

This module's intention is to be used as a template to quickly start with a new Maven-based Axon application with Spring Boot, either in Java or Kotlin.

Multi-tenant playground

This simple app allows you to experiment with multi-tenancy feature in Axon Framework. By using Multitenancy extension this app can connect to multiple contexts at once dynamically. Using UI, explore how to create tenants in runtime and dispatch messages to them.

Distributed exceptions

In this demo, we will show how to propagate errors as exceptions in a distributed environment. One of the most common ways to indicate that a logical error has occurred and that Command handling failed is to throw an exception from a Command handler. However, if the exception is directly serialized, there is no guarantee that the command sending side can properly deserialize the exception in question. That is why, by default Axon Framework will wrap any exception thrown inside a Command handler into a CommandExecutionException.

Reset Handler

This demo is meant to show how to reset a tracking token. There are 2 ways of doing that, using Axon Server API or just Axon Framework.


This is an example of how to implement a Saga. This use case is implemented in the ProcessOrderSaga. A Saga is responsible for the process between multiple bounded contexts. The Saga starts on the OrderConfirmedEvent which marks the start of the order process and contains the orderId. An essential aspect of a Saga that is it needs to have an end. An everyday use case is to end a Saga after a certain amount of time.

Set Based Consistency Validation

A type of question that occurs a lot is How can I check if an account with a particular email address already exists?. In essence, this signals the requirement to validate a set, which is a more intricate process when it comes to applications that follow the CQRS paradigm. Without going into full detail here why this is a problem, a straightforward solution is to enhance the command model by adding a small look-up table that can be queried during such a validation step. There are several ways to invoke this set validation when using Axon, several of which are shared in this repository.

Subscription Query REST

In this demo we will try achieve that our REST API feels more native and on sending a command it returns updated projection right away, instead of listening for updates on a different endpoint.

Subscription Query UI Streaming

This demo application aims to showcase how to stream the results from a Subscription Query to the UI.


This module's intention is to give insights on how to create an upcaster and how to test it. This example uses a JSON serializer.