Deploy Quarkus Faster in the Cloud With Platform.sh Using the Redis Database
In this tutorial, we'll explore how to deploy a Quarkus application with the Redis database.
Join the DZone community and get the full member experience.Join For Free
Quarkus is, in its own words, a Cloud Native, (Linux) Container First framework for writing Java applications. It has become popular because of the amazingly fast boot time and incredibly low RSS memory. In this series of articles about Quarkus, we'll teach how to deploy Quarkus with Redis.
Redis is an in-memory data structure project implementing a distributed, in-memory key-value database with optional durability. Redis supports different kinds of abstract data structures, such as strings, lists, maps, sets, sorted sets, HyperLogLogs, bitmaps, streams, and spatial indexes.
To demonstrate how possible, we'll create a simple resource to store the user with its respective country. We'll create a maven project, and the first step is to create a new project with the following command:
To make easy the test, we have the option to run a Redis instance locally, and thanks to Docker.
Once we have the Redis server running, we need to configure the Redis connection properties. This is done in the
application.properties configuration file. Edit it to the following content:
Don't worry about the production environment; thanks to the configuration, we'll overwrite it without change a single line of code.
Both the project and the local infra is ready; the next step is the entity of our sample application. We'll create a User entity.
The next class will the service, where it will abstract the interaction with the Redis database. Quarkus provides a template to work to both synchronous and reactive.
The last class is the resource, where it will interact with the user client.
The application is ready; let's test it locally. In the Quarkus that is extremely easy.
That is time to explore the API:
The application is ready to go, you can run the test the application. The next step is to move to the cloud with Platform.sh.
To move your application to the cloud, briefly, you need three files:
The application file, to define who to build and run the container.
To define the services that your application need, you don't worry about maintaining, Platform.sh will handle that for you.
The last is to define the route, this file will define with the application will have public access and how.
The application is now ready, so it’s time to move it to the cloud with Platform.sh using the following steps:
- Create a new free trial account.
- Sign up with a new user and password, or login using a current GitHub, Bitbucket, or Google account. If you use a third-party login, you’ll be able to set a password for your Platform.sh account later.
- Select the region of the world where your site should live.
- Select the blank template.
Done! We have a simple and nice Quarkus application ready to go to the cloud.
Opinions expressed by DZone contributors are their own.