This example-rich tutorial shows how to design and manage large-scale Java applications as a collection of microservices. Starting with an overview of microservices from a Java EE perspective, you'll learn how to refactor your existing applications as microservices and build microservice-based applications from scratch. You'll power through practical tutorials as you call and connect microservices, understand what load balancing is, and use Netflix Hystrix for fault tolerance. You'll also master security and testing, as well as deploying to the cloud.
Part 1: Getting Started
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. Why Hate the Monolith?
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
2. Developing a Simple RESTFul Microservice
2.1. Introducing the Simple Microservice
2.1.1. Address Management application
2.1.2. Application Use Cases
2.1.3. Architecture of the Application
2.2. Creating RESTFul endpoints with JAX-RS
2.2.1. View all addresses
2.2.2. Delete an address
2.2.3. Add an address
2.2.4. Run it
3. Just enough Application Server for Microservices
3.1. Just enough Application Server
3.1.1. What does it mean?
3.1.2. What are the benefits?
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. WildFly Swarm - The Most Flexible JeAS Runtime
3.2.6. How do they compare?
Part 2: Microservices with Enterprise Java
4. Consuming Microservices
4.1. Consuming a Microservice with a Java Client Library
4.1.2. Apache HttpClient
4.2. Consuming a Microservice with a JAX-RS Client Library
4.2.1. JAX-RS Client
4.2.2. RESTEasy Client
4.3. Consuming a Microservice with WildFly Swarm
4.3.1. Simplified Client usage
5. Discovering Microservices for Consumption
5.1. Why does a Microservice need to be discovered?
5.1.1. What is Service Discovery?
5.1.2. What are the benefits of Service Discovery and a Registry?
5.1.3. What is Netflix Ribbon?
5.2. Registering a Microservice with WildFly Swarm
5.2.1. WildFly Swarm’s Topologies
5.2.2. Registering a Microservice with a Topology
5.3. Consuming a Registered Microservice with WildFly Swarm
5.3.1. Service Lookup with Netflix Ribbon
5.3.2. Service Lookup with RESTEasy Client
5.3.3. Scaling Microservices with our Example
6. Strategies for Fault Tolerance and Monitoring
6.1. Microservice Failures in a Distributed Architecture
6.1.1. Network Failures
6.2. Mitigating Against Failures
6.2.1. What is Hystrix?
6.2.2. Circuit Breakers
6.2.5. Request Caching
6.2.6. Putting it all together
6.2.7. Hystrix Dashboard
6.3. Adding Hystrix to our Message Microservice
6.3.1. Hystrix with RESTEasy Client
6.3.2. Hystrix with Ribbon Client
7. Client Side Load Balancing and Service Registries
Part 3: Breaking Down a "Monolith"
8. Architecting a Microservice Hybrid
9. Splitting out our First Microservice
10. Integrating the Microservice into the "Monolith"
11. Incorporating additional Microservices
12. Deploying to the Cloud
13. API Gateways
About the Technology
Over time, enterprise-grade Java applications can become giant hulking beasts of intertwined code, bloated with third-party libraries, and vulnerable to total collapse when a single part fails. It doesn't have to be that way! Microservices break down a large application into smaller components, each interacting with each other to create a united whole. As each component can start, stop, and scale independently, so the whole system benefits from better fault-tolerance and resilience. Equally-important, separating the application into smaller independent services makes it substantially easier to efficiently manage the development and incremental improvement of your system.
- The microservices mental model
- Fault tolerance with Netflix Hystrix
- Securing your microservices
- Deploying to the cloud
About the reader
This book is for Java developers familiar with distributed n-tier application architecture.