Build microservices-based enterprise applications with the latest version of Java EE.
Key Features:
* Create microservices in Spring and deploy them with Docker and Mesos
* Examine a number of real-world use cases and hands-on code examples
* Develop distributed applications based on microservices architecture
Book Description:
Cloud-based applications have been increasingly in demand, and this has caused a shift from monolithic to microservice applications. With the help of Java EE 8 Microservices, you'll get to grips with the components of Java EE 8 and understand how they are used to implement microservices. This book explains how a monolithic application is transformed into a microservice application, then helps you connect it in a traditional way and use advanced approaches for asynchronous communication. Once you have learned the basics, you'll explore advanced topics to make your microservices robust, scalable, and secure. Microservices form distributed applications, and by the end of this book you'll have discovered how to develop, pack, ship, and support distributed applications using Java EE.
What you will learn:
* Build microservices from the ground up with Java EE 8
* Implement and deploy microservices with Spring Boot
* Develop reactive pipelines for asynchronous communication
* Use caching mechanisms and JSON Web Token (JWT) to create scalable and secure microservices
* Empower microservices with the Micro Profile effort and implement health checks, fault tolerance, and monitoring mechanisms
* Use containers to build and deploy microservices
* Create contract-first documentation with Swagger and API Blueprint
Who this book is for:
Java EE 8 Microservices is for Java EE developers keen to build microservice-based enterprise applications.
Author(s): Kamalmeet Singh, Pavel Pscheidl et al.
Edition: 1
Publisher: Packt
Year: 2020
Language: English
Pages: 260
Tags: java ee 8 microservices openapi swagger
Cover......Page 1
Title Page......Page 2
Copyright and Credits......Page 3
About Packt......Page 4
Contributors......Page 5
Table of Contents......Page 8
Preface......Page 12
What is Monolith design?......Page 17
The challenges associated with Monolith design......Page 19
Service-oriented architecture......Page 20
Understanding Microservices......Page 22
Advantages of Microservices......Page 25
Challenges with Microservices......Page 26
Summary......Page 27
Chapter 2: Creating your first Microservice......Page 28
Setting up the Development Environment......Page 29
Installing Java Development Kit......Page 30
Installing Apache Maven......Page 31
cURL......Page 32
Creating the project with Maven......Page 33
Your very first Microservice......Page 34
Coding the Microservice......Page 35
Configuring the Microservice......Page 38
Code summary......Page 39
Running the Microservice......Page 40
Building and running the Weather Microservice......Page 41
Invoking the Microservice......Page 42
Creating the project with Maven......Page 44
Coding a Spring Boot Microservice......Page 48
Building the Spring Boot Weather Microservice......Page 54
Running the Spring Boot Weather Microservice......Page 56
Summary......Page 58
Chapter 3: Connecting Microservices Together......Page 59
Building a client......Page 60
Using third-party reactive frameworks......Page 64
Connecting two Microservices together......Page 66
Creating and pooling web targets......Page 70
Running Snoop and registering our service......Page 71
Consuming registered services......Page 74
Installing Eureka Server......Page 75
Registering the service......Page 77
Discovering and invoking the service......Page 79
Summary......Page 80
Speeding up services with the Reactive API......Page 81
Collecting results of multiple parallel calls......Page 83
Completing a REST response asynchronously......Page 85
Specifying and handling asynchronous timeouts......Page 88
A complete reactive REST service......Page 89
Simplifying the code with a third-party reactive framework......Page 90
Building an asynchronous service......Page 92
Invoking the SSE service......Page 95
Invoking the SSE service from JavaScript......Page 97
Building an SSE Java client......Page 98
Automatically reconnecting of SSE clients......Page 101
Two-way asynchronous services with WebSocket......Page 103
A quick comparison between HTTP and WebSockets......Page 104
Decoupling services with message-oriented middleware......Page 105
An example of message-oriented middleware......Page 107
Summary......Page 110
Building for failure......Page 111
Isolating the failure......Page 112
The bulkhead pattern......Page 115
Stateless services......Page 116
The robustness principle......Page 117
Asynchronous communication......Page 118
Circuit breakers......Page 119
A circuit breaker code example......Page 123
Fan out and fastest response......Page 126
Preparing for failure......Page 127
Summary......Page 128
What is scalability?......Page 129
Stateless versus Stateful scalability......Page 131
Scaling on the cloud......Page 136
Going serverless with microservices......Page 138
Scaling databases with Microservices......Page 144
Scaling Microservices with caching......Page 149
Summary......Page 152
Anatomy of a JWT......Page 153
Java Security API – JSR 375......Page 155
Basic HTTP Authentication......Page 156
Custom form-based Authentication......Page 157
Built-in and Custom IdentityStores......Page 158
The security context API......Page 159
Spring Security with Spring-Boot-based Microservices......Page 160
Configuring Spring Security with the In-memory realm......Page 165
Configuring Spring Security with the database realm......Page 166
HTTPS – The Secured Protocol......Page 168
Summary......Page 169
What is monitoring and why is it required?......Page 170
Monitoring Microservices......Page 171
Understanding core concepts and terms......Page 173
Taking a closer look using an example......Page 174
Creating the example services......Page 175
Monitoring Microservices with Zipkin......Page 179
Case 1 – service is unresponsive......Page 182
Case 2 – service responding slowly......Page 184
Prometheus for monitoring and alerting......Page 186
Elasticsearch, Logstash, and Kibana (ELK)......Page 188
Considering more tools......Page 189
Summary......Page 190
Chapter 9: Building, Packaging, and Running Microservices......Page 191
Introduction to Java Packaging......Page 192
Understanding Archives......Page 193
FatJAR packaging......Page 195
OpenLiberty......Page 197
The OpenLiberty Maven plugin......Page 198
Configuring OpenLiberty......Page 200
The Weather Microservice with OpenLiberty......Page 202
The Gradle plugin......Page 204
The WildFly Swarm generator......Page 206
The WildFly Swarm Maven plugin......Page 207
HollowJAR......Page 212
Payara Micro......Page 213
The Payara Micro Maven plugin......Page 214
The Payara Micro UberJar......Page 217
The Deployment Architecture for Microservices......Page 218
Summary......Page 220
Chapter 10: Documenting and Testing MicroServices......Page 221
Documenting Microservices......Page 222
Swagger......Page 223
APIdoc......Page 229
Testing Microservices......Page 233
Unit testing......Page 234
Integration Testing......Page 237
Service Testing......Page 239
End-to-end testing......Page 240
Levels of Testing......Page 241
Summary......Page 243
Other Books You May Enjoy......Page 244
Index......Page 247