Skip to content
Showcases in a web application Quarkus and Infinispan
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


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

  • Full-text query

  • Continuous query

Quarkus features:

  • REST web-service

  • Web Socket

  • Task Scheduling

  • Application properties

  • Application lifecycle events listeners

The demo is composed by two applications that run independently:

  • Hogwarts monitoring

  • Wizards magic

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 file under src/main/resources/META-INF folder in each application and configure infinispan.client.hotrod.client_intelligence=BASIC

Option 2: Download and run the server

  • Download the server from here

  • Unzip the file

  • Run a standalone server from the installation folder: ./bin/

Hogwarts Monitoring

Characters can execute spells, and we want to monitor who is in Hogwarts and performing magic.

  • A Character has an id, name, biography and type (other, student, teacher, muggle).

  • A Spell has an id, name and description.

  • A Spell is performed by a character. This character may or may not be at Hogwarts.

Data loading

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 create.magic property to false in the

A simple REST service is available to query characters by id or perform a full-text search of the name or the biography.

Magic Socket

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.

Hogwarts Monitoring WebSocket

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.

Go to 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.

Build and run the demo with jar
mvn clean package
cd target
java -jar hogwarts-monitoring-runner.jar
Build and run the application in native mode
mvn package -Pnative
cd target

Loaded data

Maven copies hp_characters.csv and 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.

Running the jar
java -jar  -Dcharacters.filename=/my/path/hp_characters.csv -Dspells.filename=/my/path/hp_spells.csv hogwarts-monitoring-runner.jar
Running the native
./hogwarts-monitoring-runner -Dcharacters.filename=/my/path/hp_characters.csv -Dspells.filename=/my/path/hp_spells.csv

Wizards Magic

THe wizards-magic application is a simple web application that allows to curse!

Run this application as explained above. The application will be available in http://localhost:8082

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.

Using MiniShift

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

Run Minishift
> ./minishift/
> minishift start

You should be able to access to the console

The server is accessible via web 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

OpenShift web interface

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.

Today the 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:

docker images

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
You can’t perform that action at this time.