Introduction
In this workshop, you learn how to implement reactive endpoints with Java, Quarkus, and Eclipse MicroProfile. You deploy an end-to-end sample application to Red Hat® OpenShift® on IBM Cloud®. The open source code is available as part of the Cloud Native Starter project.
One key benefit of reactive systems and reactive REST endpoints is efficiency. This workshop describes how to use reactive systems and reactive programming to achieve faster response times. This model saves you money, especially in public clouds where costs depend on CPU, RAM, and compute durations.
This workshop uses a sample application to demonstrate reactive functionality. The simple application displays links to articles and author information. The sample contains a Web-API
service with two versions of the /articles
endpoint. One uses imperative code and the other one uses reactive code. In this workshop you re-implement a simplified version of the reactive version yourself.
The reactive stack of this sample provides response times that take less than half of the time compared to the imperative stack:
Reactive | Imperative |
---|---|
793 ms | 1956 ms |
If you want to know more details, read the documentation of the performance tests.
The following two architecture diagrams explain the flow between the different components and microservices of the application. In the first diagram:
- The
API Client
invokes theWeb-API
service, which implements a back-end for front-end pattern. - The
Web-API
service invokes the two microservices ofAuthors
andArticles
. TheArticles
service reads data from Postgres.
In this workshop, you deploy the full application as described in the first diagram. But to simplify the workshop, you re-implement a simpler version of the Web-API
service, which only invokes the Articles
service. This is illustrated in the following diagram:
Objectives
After you complete this workshop, you’ll understand the following reactive functionality:
- Reactive REST endpoints via
CompletionStage
- Exception handling in chained reactive invocations
- Timeouts via
CompletableFuture
- Reactive REST invocations via MicroProfile REST Client
The intention of this workshop is not to explain every aspect of reactive programming, but to explain core reactive principles and to deploy a complete reactive application which you can inspect after the workshop in more detail.
Estimated time
This beginner level workshop will take you about one hour to complete.
Labs
- Create your cloud environment
- Deploy the example application with a script
- Develop reactive endpoints
- Invoke endpoints reactively
- Deploy your service to OpenShift
- (Optional) Use distributed logging
Next steps
After you finish the labs within this workshop, try the Reactive messaging with Quarkus on OpenShift workshop, which focuses on focusses on messaging with Kafka. It uses the same sample Web application as this one.