The application contains 3 major parts, you need all of them to be able to execute commands successfully.
- Infra components, Axon Server, Axon Synapse and MongoDB. Start with
docker console up -d
in thedocker
folder. In projection we assume the Deno app can be reached viahttp://host.docker.internal:3000/events
from Synapse which might not be the case in your docker setup. - JVM app which handles commands, builds his own projection, and has a basic ui. Run
./mvnw spring-boot:run
in the main folder to start. You do need Java installed. - A Deno app, which has its own projection in MongoDB, Run
deno run --allow-net --allow-read --import-map ./import_map.json server.ts
in thedeno
folder, you do need to have Deno installed.
- The Axon Reference Guide is definitive guide on the Axon Framework and Axon Server.
- Visit www.axoniq.io to find out about AxonIQ, the team behind the Axon Framework and Server.
- Subscribe to the AxonIQ YouTube channel to get the latest Webinars, announcements, and customer stories.
- To start a fresh Axon Application, you can go to start.axoniq.io.
- Additional information may be gained by following some of AxonIQ's courses on the AxonIQ Academy.
- The latest version of the Giftcard App can be found on GitHub.
- Docker images for Axon Server are pushed to Docker Hub.
- If there are any Axon related questions remaining, you can always go to the forum.
More information about some of the components involved
It's a Axon Framework application, which has been forked. The fork might diverge at some points. The major difference is that within this project, its using MongoDB to store the projection.
See the wikipedia article for a basic definition of gift cards. Essentially, there are just two events in the life cycle of a gift card:
- They get issued: a new gift card gets created with some amount of money stored.
- They get redeemed: all or part of the monetary value stored on the gift card is used to purchase something.
The Giftcard application is split into four parts, using four sub-packages of io.axoniq.demo.giftcard
:
- The
api
package contains the (Java Records) sourcecode of the messages and entity. They form the API (sic) of the application. - The
command
package contains the GiftCard Aggregate class, with all command- and associated eventsourcing handlers. - The
query
package provides the query handlers, with their associated event handlers. - The
rest
package contains the Spring Webflux-based Web API.
To build the demo app, simply run the provided Maven wrapper:
./mvnw clean package
Note that the Giftcard app expects JDK 17 to be used.
The simplest way to run the app is by using the Spring-boot maven plugin:
./mvnw spring-boot:run
However, if you have copied the jar file giftcard-demo-1.0.jar
from the Maven target
directory to some other location, you can also start it with:
java -jar giftcard-demo-1.0.jar
The Web GUI can be found at http://localhost:8080
.
Axon server is both a event store and a message router. It was developed to work well together with Axon Framework applications.
By default, the Axon Framework is configured to expect a running Axon Server instance, and it will complain if the server is not found.
To run Axon Server, you'll need a Java runtime.
A copy of the server JAR file has been provided in the demo package.
You can run it locally, in a Docker container or on a separate server.
The section below give a fair description on how to run Axon Server for this sample project. If you are looking for more in depth information on the subject, we recommend this three-part blog series:
- Running Axon Server - Going from local developer install to full-featured cluster in the cloud
- Running Axon Server in Docker - Continuing from local developer install to containerized
- Running Axon Server in a Virtual Machine
To run Axon Server locally, all you need to do is put the server JAR file in the directory where you want it to live, and start it using:
java -jar axonserver.jar
You will see that it creates a subdirectory data
where it will store its information.
To run Axon Server in Docker you can use the image provided on Docker Hub:
$ docker run -d --name my-axon-server -p 8024:8024 -p 8124:8124 axoniq/axonserver
...some container id...
$
Axon Server uses sensible defaults for all of its settings, so it will actually run fine without any further configuration. However, if you want to make some we recommend checking out the Configuration section of the Reference Guide.
Axon Server provides two servers; one serving HTTP requests, the other gRPC. By default, these use ports 8024 and 8124 respectively, but you can change these in the settings.
The HTTP server has in its root context a management Web GUI, a health indicator is available at /actuator/health
, and the REST API at /v1
.
The API's Swagger endpoint finally, is available at /swagger-ui.html
, and gives the documentation on the REST API.
Axon Synapse has its own ui, available at localhost:8081
when using the docker compose. You can see things like which applications are connected.
You need to have Deno installed. If you are on a mac, you can run:
brew install deno
After that, you can run the deno app with:
cd deno
deno run --allow-net --allow-read --import-map ./import_map.json server.ts