- Harry Potter Quarkus Demo
- Before running the demo
- Hogwarts Monitoring
- Wizards Magic
Harry Potter Quarkus Demo
The main goal of this demo is to showcase how to use Infinispan client with Quarkus.
Infinispan features that are being used:
Create stores dynamically
Simple get/put operations
Application lifecycle events listeners
The demo is composed by two applications that run independently:
Each application has a dedicated section in this documentation
Before running the demo
Quarkus uses Infinispan Remote Client. You need to have an Infinispan Server running before you run this demo.
Option 1: Use Docker
docker run -it -p 11222:11222 jboss/infinispan-server:latest
Docker for mac users. There is a known issue to connect with the server using the hotrod client.
Blog post here.
You won’t need to do this in production, but for testing/development purposes, if you want to connect to a Infinispan
Server running in a Docker container, create
Option 2: Download and run the server
Download the server from here
Unzip the file
Run a standalone server from the installation folder:
Characters can execute spells, and we want to monitor who is in Hogwarts and performing magic.
Characterhas an id, name, biography and type (other, student, teacher, muggle).
Spellhas an id, name and description.
Spellis performed by a character. This character may or may not be at Hogwarts.
DataLoader class loads characters and spells in two separate stores.
This is done at startup time
Magic is going on
Hogwarts Magic Creator is going to emulate characters performing some magic. It will randomly pick a character and a spell to perform (if they can)! Characters in Hogwarts are teachers or students.
To disable this service, set
A simple REST service is available to query characters by id or perform a full-text search of the name or the biography.
A socket that performs a Continuous Query making it possible to monitor which characters in Hogwarts are currently performing magic. The continuous query does not have to go to the server and it is all stored in the client application itself. Read more about these queries in the official Infinispan documentation.
Run Hogwarts Monitoring in dev mode
To run in development mode, just run
mvn clean compile quarkus:dev. This allows for hot swapping the application, so you can tweak parts of it
and it will automatically redeploy.
http://localhost:8081 and monitor the magic!
You will be connected to the monitoring socket. The interface displays some links to display a character by id and perform a full-text search.
mvn clean package cd target java -jar hogwarts-monitoring-runner.jar
mvn package -Pnative cd target ./hogwarts-monitoring-runner
hp_spells.csv`to the target directory, that’s why it’s easier to run the executables
from the `target folder. However you can override these files location at runtime.
java -jar -Dcharacters.filename=/my/path/hp_characters.csv -Dspells.filename=/my/path/hp_spells.csv hogwarts-monitoring-runner.jar
./hogwarts-monitoring-runner -Dcharacters.filename=/my/path/hp_characters.csv -Dspells.filename=/my/path/hp_spells.csv
wizards-magic application is a simple web application that allows to curse!
Run this application as explained above. The application will be available in
A simple form will be displayed. You can add you name, pick a curse and tell which kind of Wizard you are. If the Hogwarts monitoring is running, you should be able to see your curse displayed… If you chose to be a teacher or a student, of course!
In this part we will be deploying both modules in OpenShift. We are going to install Infinispan in OpenShift using Operators. To make this possible you need administration rights. Operators are supported for OpenShift 4 or 3.11.
A simple way to deploy locally and test, you can use MiniShift.
Important: This tutorial user VirtualBox, but this can be changed in the setup file
Once MiniShift is installed
> ./minishift/setup-minishift.sh > minishift start
You should be able to access to the console
Install Infinispan Cluster
This file contains all the necessary commands to install the operator and the Infinispan Cluster.
You can access to OpenShift console
Build each application
For both applications execute the following steps:
Configure infinispan-client.server-list property
The application is going to be deployed in OpenShift, and will connect to the Infinispan Cluster that is available.
quarkus.infinispan-client.server-list is a build time property. This means that the current version of
Quarkus does not allow to override the value dynamically.
Before building the application, change this value so the application will be able to connect to the Infinispan Cluster once it will be deployed in OpenShift :
Build each application native, but for docker
mvn clean package -Pnative -Dnative-image.docker-build=true
Deploy the application
You have two options.
Option 1: Use Docker Registry
An image of the applications are available in the public docker hub:
You can deploy an image from the OpenShift web console.
Option 2: Use OpenShift build
oc new-build --binary --name=-oc-hogwarts-monitoring -l app=oc-hogwarts-monitoring oc start-build oc-hogwarts-monitoring --from-dir=. --follow oc new-app --image-stream=oc-hogwarts-monitoring:latest
oc new-build --binary --name=-oc-wizards-magic -l app=oc-wizards-magic oc start-build oc-wizards-magic --from-dir=. --follow oc new-app --image-stream=oc-wizards-magic:latest
You will see that the applications are deployed and the logs can be displayed.
Access to the applications with the browser
If you want to access to the interfaces on the browser, you need to expose a service.
oc expose service oc-hogwarts-monitoring
oc expose service oc-wizards-magic