Book Image

Hands-On Cloud Development with WildFly

By : Tomasz Adamski
Book Image

Hands-On Cloud Development with WildFly

By: Tomasz Adamski

Overview of this book

The book starts by introducing you to WildFly Swarm—a tool that allows you to create runnable microservices from Java EE components. You’ll learn the basics of Swarm operation—creating microservices containing only the parts of enterprise runtime needed in a specific case. Later, you’ll learn how to configure and test those services. In order to deploy our services in the cloud, we’ll use OpenShift. You’ll get to know basic information on its architecture, features, and relationship to Docker and Kubernetes. Later, you’ll learn how to deploy and configure your services to run in the OpenShift cloud. In the last part of the book, you’ll see how to make your application production-ready. You’ll find out how to configure continuous integration for your services using Jenkins, make your application resistant to network failures using Hystrix, and how to secure them using Keycloak. By the end of the book, you’ll have a functional example application and will have practical knowledge of Java EE cloud development that can be used as a reference in your other projects.
Table of Contents (14 chapters)

The goal of the book

As you are going to learn in this book, you are able to use your existing Java EE knowledge to create microservices architecture. This knowledge will not be sufficient though, because, as we mentioned in the Microservices section, this kind of architecture introduces its own complexity, which has to be handled.

The goal of this book is to fill this knowledge gap by providing you with a practical, hands-on introduction to the development of microservice-based applications running on cloud infrastructures. This book makes an assumption that you are familiar with Java EE and the traditional way of developing Java EE applications. It will complement this knowledge with the information about a concrete set of tools that will allow you to immediately take advantage of both cloud computing and microservices.

We will like to emphasize that this book does not advertise any particular methodology, and, as we mentioned in the Microservices section, any architecture decision should be made with regard to the concrete project, taking into consideration all the advantages and disadvantages. Our goal is to provide you with a set of tools so that if you decide to make such a transition, you will immediately know what to do.

Throughout the book, we will develop a sample application, which will serve as a base for all our examples. Let's learn more about it now.

The pet store application

Computer programming books often start with the Hello World application. Similarly, books describing a framework often develop a pet store application. We will follow this tradition. The pet store that we will develop will be a simple application that will allow you to browse the catalog of pets, add some of them to your cart, and finalize the payment.

During the development of the application, we will be concentrating on cloud and microservice aspects. The service code is simple and uses basic Java EE technologies so that the reader can concentrate on what is being taught in this book: cloud integration and microservices development.

Let's take the bird's-eye view of the application:

The backend services (red), gateways (yellow), and security server (blue) are deployed in a cloud. The UI application (green) is deployed outside the cloud.

The gateway services are responsible for providing APIs for different users. The customer gateway provides an API for customers, which is used by petstore-ui—web-client implementing the store interface. The customer gateway orchestrates invocations to the underlying base services and is accessible from outside the cloud.

The security service is responsible for the authentication and authorization of access to different parts of the API. It is used by all other components. The security service is accessible from outside the cloud.

The core functionalities are implemented by backend services. Backend services are not accessible from the gateway service. Let's take a look at their functions:

  • Catalog service: Provides information about pets available in the store
  • Pricing service: Responsible for providing the price of a given pet
  • Cart service: Responsible for keeping information about the cart of a given customer

We will develop the application step by step throughout the book. The application is attached to the book, and as a result, you could work with it immediately while learning various concepts described in the book.

The technologies used

We will convert our traditional Java EE JARs into runnable ones using WildFly Swarm—the tool that we will introduce in Chapter 2, Get Familiar with WildFly Swarm. WildFly Swarm is able to wrap our application into a JAR containing a minimal number of libraries needed for it, effectively creating microservices from a deployable JAR. We will cover how Swarm does it in Chapter 3, Right-Size Your Applications, and how to configure the created services in Chapter 4, Tuning the Configuration of Your Services.

After services are written, we have to write tests for them. We will use the Arquillian library to do it. We will discuss how to use it in Chapter 5, Testing Your Services with Arquillian.

We will deploy the created services in cloud using OpenShift. In Chapter 6, Deploying Applications on the Cloud with OpenShift, we will give you a theoretical introduction to the platform, the API, and tools that it provides. In Chapter 7, Configuring Persistent Storage for your Applications, we will discuss how to configure persistent storage for our applications on OpenShift and how to scale and connect our services.

Creating and deploying applications in cloud is not enough for them to be ready for production. We still need to secure them, monitor them, and take care of network failures.

To provide security, we will take advantage of the Keycloak server. In order to take care of network failures, we will use the Hystrix library. In order to provide monitoring.