Enterprise Java Microservices
Ken Finnigan
  • September 2018
  • ISBN 9781617294242
  • 272 pages
  • printed in black & white
pBook available Oct 25, 2018

Frameworks, patterns, and concepts that Java developers need to be successful in a microservices world.

Andrew Block, Red Hat

Enterprise Java Microservices is an example-rich tutorial that shows how to design and manage large-scale Java applications as a collection of microservices.

Table of Contents detailed table of contents

Part 1: Microservices Basics

1 Enterprise Java microservices

1.1 Enterprise Java pitfalls

1.1.1 What is Enterprise Java?

1.1.2 Typical Enterprise Java Architecture

1.1.3 What is a Monolith?

1.1.4 What are the problems associated with monoliths?

1.2 Microservices and Distributed Architecture

1.2.1 Do One Thing Well

1.2.2 What is a Distributed Architecture?

1.2.3 Why should I care about being Distributed?

1.2.4 What can be done to assist in developing microservices?

1.2.5 Product over Project

1.2.6 Continuous integration and delivery

1.3 Patterns for migration to microservices

1.3.1 Domain Driven Design

1.3.2 Big Bang Pattern

1.3.3 Strangler Pattern

1.3.4 Hybrid Pattern

1.4 What are Enterprise Java microservices?

1.4.1 Why Enterprise Java is a good fit for microservices

Summary

2 Developing a Simple RESTFul microservice

2.1 Cayambe Monolith

2.2 New administration site

2.2.1 Use cases

2.2.2 Architecture of the application

2.2.3 Creating RESTFul endpoints with JAX-RS

2.2.4 Running it

Summary

3 Just enough Application Server for microservices

3.1 Just enough Application Server

3.1.1 3.1.1 What does JeAS mean?

3.1.2 What are the benefits?

3.1.3 Eclipse MicroProfile

3.2 Choosing Just enough Application Server

3.2.1 Beach Vacation example application

3.2.2 Dropwizard — The Original Opinionated microservice runtime

3.2.3 Payara Micro — Slimmed Java EE App Server in a Jar

3.2.4 Spring Boot — Opinionated Spring microservices

3.2.5 Thorntail — The most flexible JeAS runtime

3.2.6 How do they compare?

Summary

4 Microservice Testing

4.1 What type of testing do we need?

4.2 Unit testing

4.3 What is immutability?

4.4 Integration Testing

4.5 Consumer Driven Contract Testing

4.6 Additional Reading

4.7 Additional Exercises

Summary

5 Cloud Native Development

5.1 What is Cloud anyway?

5.2 Service Models

5.3 Cloud Native Development

5.4 Deploying to the Cloud

5.5 Starting Minishift

5.6 Microservice Cloud deployment

5.7 Testing in the Cloud

5.8 Additional Exercises

Summary

Part 2: Implementing Enterprise Java microservices

6 Consuming microservices

6.1 Consuming a microservice with a Java Client Library

6.1.1 java.net

6.1.2 Apache HttpClient

6.2 Consuming a microservice with a JAX-RS Client Library

6.2.1 JAX-RS Client

6.2.2 RESTEasy Client

Summary

7 Discovering microservices for Consumption

7.1 Why does a microservice need to be discovered?

7.1.1 What is Service Discovery?

7.1.2 What are the benefits of Service Discovery and a Registry?

7.1.3 Stateless vs Stateful microservices

7.1.4 What is Netflix Ribbon?

7.2 Registering a microservice with Thorntail

7.2.1 Thorntail’s Topologies

7.2.2 Registering a microservice with a Topology

7.3 Consuming a registered microservice with Thorntail

7.3.1 Service lookup with Netflix Ribbon

7.3.2 Service lookup with RESTEasy Client

Summary

8 Strategies for Fault Tolerance and Monitoring

8.1 Microservice Failures in a Distributed Architecture

8.2 Network Failures

8.3 Mitigating Against Failures

8.3.1 What is Hystrix?

8.3.2 Circuit Breakers

8.3.3 Bulkheads

8.3.4 Fallbacks

8.3.5 Request caching

8.3.6 Putting it all together

8.3.7 Hystrix Dashboard

8.4 Adding Hystrix to our Payment microservice

8.4.1 Hystrix with RESTEasy Client

8.4.2 Hystrix with Ribbon Client

Summary

9 Securing a Microservice

9.1 Importance of Securing microservice

9.1.1 Why is Security Important?

9.1.2 What does it need to solve?

9.2 Working with Keycloak

9.2.1 Understanding Keycloak’s features

9.2.2 Setting up Keycloak

9.3 Securing Stripe microservice

9.3.1 Configuring Keycloak

9.3.2 Securing the Stripe resource

9.3.3 Authenticating in the Payment resource

9.3.4 Testing your secured microservice

9.4 Capturing user authentication

9.4.1 Configuring Keycloak

9.4.2 Securing category deletion

9.4.3 Authenticating the user in a UI

9.4.4 Testing that the new UI and service all work

Summary

10 Architecting a microservice hybrid

10.1 The Cayambe monolith

10.2 Running the Cayambe monolith

10.2.1 Database setup

10.2.2 WildFly setup

10.2.3 Running Cayambe

10.3 Cayambe hybrid—​monolith with microservices

10.3.1 Integrating Payment microservice

10.3.2 Integrating Admin microservice

10.3.3 New administration UI

10.3.4 Cayambe hybrid summary

10.4 Deploying everything to a Hybrid Cloud

10.4.1 Database

10.4.2 Security

10.4.3 Microservices

10.4.4 Cayambe hybrid

10.4.5 Cayambe EAR

10.4.6 Admin UI

Summary

11 Data Streaming with Apache Kafka

11.1 What can Apache Kafka do for you?

11.1.1 Data Streaming

11.1.2 Apache Kafka

11.2 Simplifying your monolith architecture with streaming

11.3 Deploying and using Kafka for data streaming

11.3.1 Kafka on OpenShift

11.3.2 Admin microservice

11.3.3 Kafka consumer

11.4 Additional exercises

Summary

Appendixes

Appendix A: Spring Boot microservices

Anatomy of a Spring Boot project

Examining a newly initialized Spring Boot project

Bootstrapping Spring

Testing Spring Boot applications

Configuring application properties

Spring Boot starter dependencies

Using starter dependencies

Specifying facet-based dependencies

Overriding starter transitive dependencies

Developing a Spring Boot application

Focusing on application functionality

Defining the domain

Defining the repository interface

Creating the web interface

Spring Boot testing

Mocking Spring MVC

Summary

About the Technology

Large applications are easier to develop and maintain when you build them from small, simple components. Java developers now enjoy a wide range of tools that support microservices application development, including right-sized app servers, open source frameworks, and well-defined patterns. Best of all, you can build microservices applications using your existing Java skills.

About the book

Enterprise Java Microservices teaches you to design and build JVM-based microservices applications. You’ll start by learning how microservices designs compare to traditional Java EE applications. Always practical, author Ken Finnigan introduces big-picture concepts along with the tools and techniques you’ll need to implement them. You’ll discover ecosystem components like Netflix Hystrix for fault tolerance and master the Just enough Application Server (JeAS) approach. To ensure smooth operations, you’ll also examine monitoring, security, testing, and deploying to the cloud.

What's inside

  • The microservices mental model
  • Cloud-native development
  • Strategies for fault tolerance and monitoring
  • Securing your finished applications

About the reader

This book is for Java developers familiar with Java EE.

About the author

Ken Finnigan leads the Thorntail project at Red Hat, which seeks to make developing microservices for the cloud with Java and Java EE as easy as possible.


FREE domestic shipping on three or more pBooks

A complete overview of how to implement microservices in a company environment, with different solutions to the same problem given and explained.

Damián Mazzini, UBA Argentina

Covers everything a developer must know before stepping from monolith to microservices architecture.

Kelum Prabath Senanayake, Equinix

A great guide through the world of Java enterprise microservices with cool use cases and code examples.

Alexandros Koufoudakis, Red Hat