Hands-On Cloud-Native Microservices with Jakarta EE
eBook - ePub

Hands-On Cloud-Native Microservices with Jakarta EE

Build scalable and reactive microservices with Docker, Kubernetes, and OpenShift

  1. 352 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Hands-On Cloud-Native Microservices with Jakarta EE

Build scalable and reactive microservices with Docker, Kubernetes, and OpenShift

About this book

Discover how cloud-native microservice architecture helps you to build dynamically scalable applications by using the most widely used and adopted runtime environments

Key Features

  • Build robust cloud-native applications using a variety of tools
  • Understand how to configure both Amazon Web Services (AWS) and Docker clouds for high availability
  • Explore common design patterns used in building and deploying microservices architecture.

Book Description

Businesses today are evolving rapidly, and developers now face the challenge of building applications that are resilient, flexible, and native to the cloud. To achieve this, you'll need to be aware of the environment, tools, and resources that you're coding against.

The book will begin by introducing you to cloud-native architecture and simplifying the major concepts. You'll learn to build microservices in Jakarta EE using MicroProfile with Thorntail and Narayana LRA. You'll then delve into cloud-native application x-rays, understanding the MicroProfile specification and the implementation/testing of microservices. As you progress further, you'll focus on continuous integration and continuous delivery, in addition to learning how to dockerize your services. You'll also cover concepts and techniques relating to security, monitoring, and troubleshooting problems that might occur with applications after you've written them.

By the end of this book, you will be equipped with the skills you need to build highly resilient applications using cloud-native microservice architecture.

What you will learn

  • Integrate reactive principles in MicroProfile microservices architecture
  • Explore the 12-factors-app paradigm and its implications
  • Get the best out of Java versions 8 and 9 to implement a microservice based on Thorntail
  • Understand what OpenShift is and why it is so important for an elastic architecture
  • Build a Linux container image using Docker and scale the application using Kubernetes
  • Implement various patterns such as, Circuit Breaker and bulkheads
  • Get to grips with the DevOps methodology using continuous integration (CI) and continuous deployment (CD)

Who this book is for

This book is for developers with basic knowledge of Java EE and HTTP-based application principles who want to learn how to build, test and scale Java EE microservices. No prior experience of writing microservices in Java EE is required.

Frequently asked questions

Yes, you can cancel anytime from the Subscription tab in your account settings on the Perlego website. Your subscription will stay active until the end of your current billing period. Learn how to cancel your subscription.
No, books cannot be downloaded as external files, such as PDFs, for use outside of Perlego. However, you can download books within the Perlego app for offline reading on mobile or tablet. Learn more here.
Perlego offers two plans: Essential and Complete
  • Essential is ideal for learners and professionals who enjoy exploring a wide range of subjects. Access the Essential Library with 800,000+ trusted titles and best-sellers across business, personal growth, and the humanities. Includes unlimited reading time and Standard Read Aloud voice.
  • Complete: Perfect for advanced learners and researchers needing full, unrestricted access. Unlock 1.4M+ books across hundreds of subjects, including academic and specialized titles. The Complete Plan also includes advanced features like Premium Read Aloud and Research Assistant.
Both plans are available with monthly, semester, or annual billing cycles.
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Yes! You can use the Perlego app on both iOS or Android devices to read anytime, anywhere — even offline. Perfect for commutes or when you’re on the go.
Please note we cannot support devices running on iOS 13 and Android 7 or earlier. Learn more about using the app.
Yes, you can access Hands-On Cloud-Native Microservices with Jakarta EE by Luigi Fugaro, Mauro Vocale in PDF and/or ePUB format, as well as other popular books in Computer Science & Cloud Computing. We have over one million books available in our catalogue for you to explore.

Information

Building Microservices Using Thorntail

In this chapter, after seeing the evolution of architectures toward the cloud, I will cover, in detail, how to create a distributed microservice architecture using the Jakarta EE and MicroProfile specifications with Thorntail. You can choose another implementation, such as Payara or Open Liberty.
The following topics will be analyzed in detail:
  • Thorntail: The MicroProfile implementation that enables you to package your Java EE applications with just enough of the server runtime.
  • Building a fantasy football application: I will create a set of microservice implementations based on different technologies in order to demonstrate the power of this new way to design enterprise applications.
  • User interface microservices: I will analyze the micro frontend architecture and how to design the user experience with the microservices approach, and I will implement it with an example, based on Angular 6.

Thorntail

Thorntail, previously called WildFly Swarm, is an open source implementation of MicroProfile specifications. It's built on top of mature technologies, and it leverages existing expertise that has been derived from Jakarta EE specifications, patterns, and implementations.
The Thorntail project was born with WildFly/Jakarta EE, but it focuses on modern cloud applications, following the path made by MicroProfile.io (in certain ways). It initially implemented version 1.3 of MicroProfile. You can find its specifications at https://github.com/eclipse/microprofile-bom/releases/download/1.3/microprofile-spec-1.3.pdf.
At the time of writing, Thorntail is in version 2.0.0, and it includes all of the features implemented in WildFly Swarm 2018.5.0.
You can consider Thorntail as a combination of all the benefits of the mature Java EE/Jakarta EE specifications and the flexibility of the MicroProfile.io and cloud-oriented concepts, as illustrated by the following diagram:
Indeed, when you build a traditional Jakarta EE application (distributed using the standard EAR or WAR), you need to install the entire application server (for example, WildFly), and then deploy your application on top of it.
It is true that with the introduction of the web profile (starting with Java EE 6), it is possible to decrease the number of APIs and components present in the initial configuration of the application server.
Further optimizations have been made by the application servers to only load the specifications (and consequently, the classes) that our application really needs. WildFly, for example, has four basic configuration profiles, which make up only a subset of the functionalities available during the start of the application server. WildFly also loads its subsystems in a lazy way, so that its footprint is very low, and the memory usage related to loaded classes is strictly related to what the application really uses.
However, in microservice architectures, this is not enough, because with a traditional Jakarta EE application server, you could have significantly more functionality than your application requires.
Thorntail gives you the ability to create a final package that contains exactly what you need for your deployment, using two different strategies, as follows:
  • Uber JAR: A self-contained, executable Java archive that contains your application, the fractions of Thorntail required to support it, a Maven repository of dependencies, and a small library that's needed to bootstrap it all.
  • Hollow Uber JAR: A self-contained, executable Java archive that contains no application code, but only what you need to run it. Usually, it contains a subset of APIs, Jakarta EE, and MicroProfile, that your application will use. In this way, you exclude your EAR or WAR file (with the application code) from the executable Hollow JAR. Then, you can deploy your application artifact in the same style as traditional Jakarta EE app servers.
One of the key elements of Thorntail is the fraction, which will be explained in the following section.

Fractions

As we explained earlier, you can consider Thorntail as a runtime environment that you can build in a pluggable way. The core unit that represents the compositional aspect in Thorntail is the fraction. It's a well-defined runtime capability to add to your environment. In some cases, a fraction maps directly to a subsystem from WildFly, but in other cases, it may involve a different functionality that's described in the MicroProfile.io specifications or is needed in the cloud environment.
A fraction can do the following things:
  • Directly enable a WildFly subsystem as Infinispan, which is needed to implement a data caching layer
  • Integrate additional frameworks or services (for example, topology using Consul, JGroups, and OpenShift)
  • Provide deployments of features like API documentation (for example, Swagger) or JMX metrics access (for example, Jolokia)
  • Add API dependencies as Jakarta EE (for example, JAX-RS) or MicroProfile.io (for example, config, and health check)
  • Alter deployment, introducing features as single-sign on for the authentication and authorization settings of your application (for example, Keycloak).
At the time of writing, there are about 184 fractions available that are stable and experimental, and there are more in the pipeline. About 80% wrap WildFly, related components, so you are able to use some Jakarta EE specifications, and you can easily evolve your application from a monolithic to a microservice architecture.
Fractions support explicit and implicit configuration; in many cases, you won't need to configure anything. The default values will let you successfully run your application.
Fractions can be detected or explicitly declared. The simplest case is a WAR project, with just the Maven plugin. After enabling the thorntail-maven-plugin inside your application, Thorntail will detect which APIs you use, and will include the fractions that implement them at build time. The default behavior of thorntail-maven-plugin is to auto detect fractions only if you do not specify anything explicitly. You can change this setting through the fractionDetectMode property.
To implement the auto detection mode, you should implement the following steps:
  1. Add the thorntail-maven-plugin to your pom.xml in a <plugin> block, with an <execution> specifying the package goal:
<plugins>
<plugin>
<groupId>io.thorntail</groupId>
<artifactId>thorntail-maven-plugin</artifactId>
<version>${version.thorntail}</version>
<executions>
<execution>
<id>package</id>
<goals>
<goal>package</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
  1. Specify the API that you want to u...

Table of contents

  1. Title Page
  2. Copyright and Credits
  3. Contributors
  4. About Packt
  5. Preface
  6. Jakarta EE - the New Open Source Life of Java EE
  7. Microservices and Reactive Architecture
  8. Cloud-Native Applications
  9. Building Microservices Using Thorntail
  10. Eclipse MicroProfile and Transactions - Narayana LRA
  11. Linux Containers
  12. Platform as a Service
  13. Microservices Patterns
  14. Deployment
  15. Monitoring
  16. Building Microservices Using Spring Boot 2
  17. Building Microservices Using Vert.X
  18. Other Books You May Enjoy