This is a simple example on how to build your first Vert.x using Infinispan.
Examples include :
- Creating a simple REST API
- Creating and consuming a simple PUSH API
- Clustering with Infinispan
REST and PUSH APi examples use Client/Server mode and the Hot Rod protocol. Both examples need an Infinispan Server running locally. You will need an Infinispan Server to run CuteNamesRestAPITest and SendCuteNamesAPITest
The clustered example, uses the Vert.x Infinispan Cluster Manager. Each node of the clustered application uses an embedded infinispan instance. We don't need any server running. See the readme for more explanations.
You can use docker or download the server manually.
For example, if you want to test with the version 9.3.0.Final:
docker run -it -p 11222:11222 jboss/infinispan-server:9.3.0.Final
- Download the infinispan server from here
- Start Infinispan Standalone Server running
./infinispan-server/bin/standalone.sh
cd restapi
- run
mvn exec:java -Dexec.mainClass="cutenames.CuteNamesRestAPI"
You can now put and get names using curl.
curl -X POST -H "Content-Type: application/json" -d '{"id":"42", "name":"Oihana"}' "http://localhost:8081/api/cutenames"
curl -X GET -H "Content-Type: application/json" "http://localhost:8081/api/cutenames/42"
curl -X POST -H "Content-Type: application/json" -d '{"name":"Elaia"}' "http://localhost:8081/api/cutenames"
- cd
socketapi
- run
mvn exec:java -Dexec.mainClass="cutenames.SendCuteNamesAPI"
cd cute-react
- run
npm install
- run
npm start
- Go to
http://localhost:9000/
Each time a new name will be posted, the name will be displayed in the client application.
Clustered Vert.x example showcases a dummy application in cluster mode using Infinispan cluster manager. See the dedicated readme file.
The new way of deploying a Infinispan is now using the Operator framework.
Read this Infinispan Simple Tutorial to have it up and running!
The cluster created by the example above 'example-infinispan' is the host you need to use to connect with
the hotrod client. Instead localhost:11222
your server will be example-infinispan:11222
This is configured by default in the code in CacheAccessVerticle