Digital Developer Conference: Hybrid Cloud. On Sep 22 & 24, start your journey to OpenShift certification. Free registration

Build more efficient applications with reactive Java technologies

Introduction

In this article, learn how to deploy cloud-native applications on the IBM Cloud Kubernetes Service without any client-side setup. Instead, use toolchains in IBM Cloud, which contain CD/CI pipelines to build and deploy all microservices.

The sample application used in this article is available as open source in GitHub as part of the cloud-native-starter project, which describes how to get started with Java-based microservices. You can deploy the sample yourself in less than an hour (30 – 60 minutes).

Benefits of reactive applications

In the context of cloud-native applications the topic ‘reactive’ becomes more and more important, since more efficient applications can be built and user experiences can be improved.

One benefit of reactive models is the ability to update web applications by sending messages, rather than pulling for updates, which improves the user experience. The following animated figure shows how a web application is updated automatically when new objects are created using REST API invocations.

Reactive web application

Another benefit of reactive systems is efficiency. For example, reactive REST endpoints can provide much faster response times. Especially in public clouds where costs depend on CPU, RAM, and compute durations, this model saves money. In the cloud-native-starter sample, the response times are cut in half, compared to synchronous REST endpoints.

Quarkus: Supersonic Subatomic Java

The sample heavily leverages Quarkus, which is “a Kubernetes-native Java stack […] crafted from the best of breed Java libraries and standards” (“Quarkus: A quick-start guide to the Kubernetes-native Java stack,” Red Hat Developer, October 2019). Additionally Eclipse MicroProfile, Eclipse Vert.x, Apache Kafka, PostgreSQL, Eclipse OpenJ9, and Kubernetes are used.

Check out this series of blogs to learn more about how reactive applications can be built with Quarkus:

Deploying on IBM Cloud Kubernetes Service

In order to make the deployment of the sample application as easy as possible, a toolchain has been created. Client-side installations and configurations are not necessary. The toolchain installs the following components:

  • PostgreSQL and admin client
  • Kafka
  • Microservices: articles, authors, web-api
  • Web application
  • Eclipse Orion web IDE

Before you can trigger the toolchain, you need three prerequisites, which are all free: IBM id, IBM Cloud Kubernetes Service, and IBM Container Registry.

When all prerequisites are met, you can simply click a button to deploy the application. Check out this GitHub repo for step-by-step instructions.

The next screenshot shows the pipeline. The log of the last job “Deploy web-app” displays all URLs you need to access the application.

Pipeline

The definitions of the toolchain and the pipeline are available in GitHub as open source as well, which you can use as a starting point for your own toolchains.

Happy coding!