Enterprise Java Microservices

Enterprise Java Microservices

by Ken Finnigan

Paperback(1st Edition)

Members save with free shipping everyday! 
See details



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

Purchase of the print book includes a free eBook in PDF, Kindle, and ePub formats from Manning Publications.

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.

Table of Contents

  1. Enterprise Java microservices
  2. Developing a simple RESTful microservice
  3. Just enough Application Server for microservices
  4. Microservices testing
  5. Cloud native development
  6. Consuming microservices
  7. Discovering microservices for consumption
  8. Strategies for fault tolerance and monitoring
  9. Securing a microservice
  10. Architecting a microservice hybrid
  11. Data streaming with Apache Kafka

Product Details

ISBN-13: 9781617294242
Publisher: Manning Publications Company
Publication date: 11/05/2018
Edition description: 1st Edition
Pages: 272
Product dimensions: 7.30(w) x 9.20(h) x 0.80(d)

About the Author

Ken Finnigan has worked as an engineer and consultant for nearly 20 years. He currently co-leads the development of WildFly Swarm for Red Hat.

Table of Contents

Preface ix

Acknowledgments x

About this book xi

About the author xiv

About the cover illustration xv

Part 1 Microservices Basics 1

1 Enterprise Java microservices 3

1.1 Enterprise Java-a short history 4

What is Enterprise Java? 4

Typical Enterprise Java architecture 4

What is a monolith? 6

What are the problems associated with monoliths? 9

1.2 Microservices and distributed architecture 10

Do one thing well 11

What is a distributed architecture? 11

Why should you care about being distributed? 12

What can be done to assist in developing microservices? 14

Product over project 14

Continuous integration and delivery 14

1.3 Patterns for migration to microservices 15

Domain-Driven Design 15

Big Bang pattern 17

Strangler pattern 18

Hybrid pattern 18

1.4 What are Enterprise Java microservices? 19

Why Enterprise Java is a good fit for microservices 21

2 Developing a simple RESTful microservice 23

2.1 Cayambe monolith 23

2.2 New administration site 25

Use cases 27

Architecture of the application 28

Creating RESTful endpoints with JAX-RS 30

Running it 33

3 Just enough Application Server for microservices 36

3.1 Just enough Application Server 37

What does JeAS mean? 37

What are the benefits? 41

Eclipse MicroProfile 43

3.2 Choosing Just enough Application Server 44

Beach Vacation example application 44

Dropwizard-the original opinionated Microservice runtime 46

Payara Micro-slimmed Java EE app server in a JAR 49

Spring Boot-opinionated Spring microservices 53

Thorntail-the most flexible JeAS runtime 56

How do they compare? 58

4 Microservices testing 60

4.1 What type of testing do you need? 61

4.2 Unit testing 62

4.3 What is immutability? 64

4.4 Integration testing 66

4.5 Consumer-driven contract testing 74

4.6 Additional reading 82

4.7 Additional exercises 82

5 Cloud native development 83

5.1 What is the cloud anyway? 84

5.2 Service models 84

5.3 Cloud native development 86

5.4 Deploying to the cloud 88

5.5 Starting Minishift 88

5.6 Microservice cloud deployment 89

5.7 Testing in the cloud 94

5.8 Additional exercises 97

Part 2 Implementing Enterprise Java Microservices 99

6 Consuming microservices 101

6.1 Consuming a microservice with a Java client library 105

Java.net 106

Apache HttpClient 108

6.2 Consuming a microservice with a JAX-RS client library 110

JAX-RS client 110

RESTEasy client 113

7 Discovering microservices for consumption 117

7.1 Why does a microservice need to be discovered? 118

What is service discovery? 119

What are the benefits of service discovery and a registry? 120

Stateless vs. stateful microservices 123

What is Netflix Ribbon? 123

7.2 Registering a microservice with Thorntail 125

Thorntail's topologies 125

Registering a microservice with a topology 127

7.3 Consuming a registered microservice with Thorntail 131

Service lookup with Netflix Ribbon 131

Service lookup with the RESTEasy client 135

8 Strategies for fault tolerance and monitoring 138

8.1 Microservice failures in a distributed architecture 138

8.2 Network failures 141

8.3 Mitigating against failures 142

What is Hystrix? 142

Circuit breakers 145

Bulkheads 149

Fallbacks 151

Request caching 152

Putting it all together 153

Hystrix Dashboard 155

8.4 Adding Hystrix to your Payment microservice 158

Hystrix with the RESTEasy client 158

Hystrix with the Ribbon client 161

9 Securing a microservice 164

9.1 The importance of securing your microservice 164

Why is security important? 165

What problems does security need to solve? 167

9.2 Working with Keycloak 168

Understanding Keycloak's features 168

Setting up Keycloak 169

9.3 Securing the Stripe microservice 172

Configuring Keycloak 173

Securing the Stripe resource 175

Authenticating in the Payment resource 176

Testing your secured microservice 178

9.4 Capturing user authentication 180

Configuring Key cloak 180

Securing category deletion 182

Authenticating the user in a UI 183

Testing that the new UI and service all work 186

10 Architecting a microservice hybrid 188

10.1 The Cayambe monolith 189

10.2 Running the Cayambe monolith 191

Database setup 191

WildFly setup 191

Running Cayambe 193

10.3 Cayambe hybrid-monolith with microservices 194

Integrating the Payment microservice 196

Integrating the Admin microservice 202

New administration UI 202

Cayambe hybrid summary 202

10.4 Deploying everything to a hybrid cloud 203

Database 204

Security 206

Microservices 207

Cayambe hybrid 207

Cayambe EAR 209

Admin UI 209

11 Data streaming with Apache Kafka 211

11.1 What can Apache Kafka do for you? 211

Data streaming 212

Apache Kajka 213

11.2 Simplifying your monolith architecture with streaming 216

11.3 Deploying and using Kafka for data streaming 219

Kafka on OpenShift 219

Admin microservice 221

Kafka consumer 223

11.4 Additional exercises 226

Appendix Spring Boot microservices 229

Index 247

Customer Reviews