Rapid Java Persistence and Microservices (eBook)
XVII, 319 Seiten
Apress (Verlag)
978-1-4842-4476-0 (ISBN)
- Build end-to-end modern applications using microservices, persistence essentials, reactive web, and other high-performance concepts
- Master Spring's configuration options
- Secure microservices efficiently
- Monitor your services post deployment
Gain all the essentials you need to create scalable microservices, which will help you solve real challenges when deploying services into production. This book will take you through creating a scalable data layer with polygot persistence. You'll cover data access and query patterns in Spring and JPA in high-performance environments. As part of this topic, you'll see the advantages of multiple persistence frameworks in Java and especially the easy persistence offered by NoSQL databases and reactive web solutions. The last few chapters present advanced concepts that are useful for very high-performance real-time applications: you'll implement applications using Spring's good support for Web sockets in their raw form as well as for connecting to message brokers such as RabbitMQ. This can be useful for applications such as navigation systems and gaming platforms.What You Will LearnBuild end-to-end modern applications using microservices, persistence essentials, reactive web, and other high-performance concepts Master Spring's configuration optionsSecure microservices efficiently Monitor your services post deployment Who This Book Is For Java developers and architects interested in microservices.
Table of Contents 5
About the Author 12
About the Technical Reviewer 13
Acknowledgments 14
Part I: Java Ecosystem Review and Persistence Quick Start 15
Chapter 1: Introduction 16
Why Java and Why This Book 17
Current Issues with the Java Ecosystem 18
Real-World Problems and Solutions 19
Summary 20
Chapter 2: Developing Microservices with Java 21
Different Ways of Creating Microservices 22
Various Microservices Libraries in Java 22
Microservices with Various Java Frameworks 24
Spark Framework 25
Dropwizard 27
Gradle Project 28
Configuration Class 29
Model Class 30
Resource Class 30
Application Class 31
YAML File: Application.yml 32
Running the Application 33
Spring Boot 34
Summary 37
Chapter 3: Basic Persistence with Spring 38
Spring Data JPA Introduction 39
Spring Data JPA Example 42
The @OnetoMany and @ManyToone Annotations 43
Creating the Blog App 44
Application Setup 45
Enums as Datatypes in Postgresql and Mapping in JPA 49
Data Models and Repositories 53
Using CascadeType.ALL and What to Avoid 60
An @ManyToMany Example 69
Running the Application 73
The @OneToOne Annotation 74
Handling Array Types in PostgreSQL 76
JPQL Queries and Pagination with Spring Data JPA 79
Using a Common Base Repository 80
Summary 82
Part II: Solving Advanced Persistence Problems and Microservices Communication Challenges 83
Chapter 4: Common Use Cases with JPA 84
Multi-Datasource Interaction 86
Application Setup 86
Datasource Configuration 87
Data Models and Repositories 92
Service Definitions 95
Application Configuration 98
Application Class 99
Running the Application 101
Solving the N+1 Problem 102
Fetching by Using the Left Fetch Join Clause in JPQL 102
Running the Eshop Application Again 104
Fetching the User Objects First and Then Fetching the Post Objects for These Users Separately 105
Fetching as a Single Combined Result Mapped to DTOS with a Native Query 105
JPA Querying with Constructor Mapping 105
Running the Eshop Application Again for the Constructor Mapping Use Case 107
JPA Querying with Mapping to Projections 107
Running the Eshop Application Again for the Projections Use Case 110
Spring Converter Service 111
Important JPA Concepts 114
JPA Managed Entity and Its Lifecycle 114
Isolation Levels, Locking, and Performance 116
Data Read Phenomena 116
Isolation Levels 117
Interesting JPA Properties 119
Running the Eshop Application for the JPA Properties 119
Summary 123
Chapter 5: Java Persistence Without ORMs 124
Spring JDBC Template 125
Application Setup 126
Configuration and Initial Schema Script 127
DTO and Application Class 128
Test Case 129
Running the Eshop-JDBC-Template-ch5 Application Test Case 131
Spring Data JDBC 132
Application Setup 134
Configuration and Initial Schema Script 134
Domain Models and Application Class 135
Data Repository 138
The Controller Class 139
Running the Eblog-Spring-Data-JDBC-ch5 Application Test Case 140
Spring Data for NoSQLs 141
Application Setup 142
Data Models 143
Data Repositories 145
Bootstrapping 145
Test Case 146
Running the Blog-Spring-Data-Mongodb-ch5 Application Test Case 148
Additional Features 149
Summary 149
Chapter 6: Deep Dive Into Microservices Development with Java 150
Interservice Communication 152
Configuration Management 153
Application Setup 155
Configuration 156
Configuration Files 156
Git Repository Setup 157
Bootstrapping 158
Running the Config-Service Application 159
Service Discovery in the Microservices Architecture 161
Discovery Service Application 162
Application Setup 163
Configuration 164
Bootstrapping 165
Running the Discovery-Service Application 166
Inventory Service Application 167
Application Setup 168
Configuration 168
Full Application Code 170
Running the Inventory-Service Application 174
Eshop Application 176
Application Setup 178
Configuration 180
Data Model, Repository and Controller Class 181
Service Classes 185
Order Service Implementation Using the Eureka Client 186
Running the Eshop Application 190
Discovery Service Dashboard 192
Order Service Implementation Using Feign 193
Resiliency in the Microservices Architecture 195
Checking Hystrix 197
Request Tracing in the Microservices Architecture 200
Monitoring in the Microservices Architecture 203
Application Setup 205
Configuration 206
Application Class 207
Admin Service Client 207
Testing the Admin Service 208
Rapid-Fire Documentation 210
Java Configuration 210
Customizing Swagger 212
API Gateway 215
Application Setup 216
Configuration 217
Bootstrapping 218
Filters 218
Running the Application 220
Code Reuse Across Services 221
Microservices Security 222
Eshop Service Changes 223
Login Controller 223
Testing Token Generation 225
Gateway-Service Changes 226
Testing Gateway Authentication 228
Summary 229
Part III: Making HTTP Faster 230
Chapter 7: Java GraphQL Development 231
Important Concepts 231
How It Works 232
Advantages Over REST 233
Risks and Disadvantages 237
GraphQL Java Example 238
Application Setup 240
Schema File: Resources/Schema.Graphqls 241
Data Models and Repositories 243
Input DTOs 245
Query and Mutation Classes 246
Configuration 251
Running the eblog-graphql-ch7 Application 252
Summary 257
Chapter 8: Java Reactive Development 258
The Reactive Manifesto 258
The Reactive Streams Project 259
The RxJava (Reactive Extensions) Project 261
Reactive APIs Within Core Java 262
Reactor and Spring Reactive 262
The Reactive Blog Microservice (Built On Spring Reactive) 264
Application Setup 264
Configuration 266
Model Class and Repository Definition 267
DTO and Web Controller 268
Bootstrapping 270
Output 271
Sample Client 272
Summary 272
Chapter 9: Java Websockets Development 273
Application Setup 274
Bootstrapping 275
Tweet Handler 276
Message Service 277
Tweet Controller 279
Running the Websocket-Example-Ch9 Application 280
Summary 283
Chapter 10: Java Serverless Development 284
Application Setup 286
Functional Code 287
Running the Serverless-Example-Ch10 Application 288
Summary 289
Chapter 11: Java Messaging 290
RabbitMQ 291
Application Setup 292
Bootstrapping 293
RabbitMQ Configuration 293
Message Producer 295
Message Consumer 296
Running the Application 297
Apache Kafka 301
Kafka Tools and Build Script 301
Message Producer 302
Message Consumer 304
Running the Application Again 304
Summary 310
Chapter 12: Java Language and Ecosystem Recap 311
Improvements to Concurrent APIs 311
Basics 311
Features After Java 5 312
After Java 5 312
The Future 313
Other Improvements 313
Tools and Tips for Productivity 315
Summary 315
Index 316
Erscheint lt. Verlag | 19.6.2019 |
---|---|
Zusatzinfo | XVII, 319 p. 29 illus. |
Sprache | englisch |
Themenwelt | Informatik ► Programmiersprachen / -werkzeuge ► Java |
Schlagworte | Java • Java Persistence • Jettty • Microservices • Spring • Tomcat • undertow |
ISBN-10 | 1-4842-4476-1 / 1484244761 |
ISBN-13 | 978-1-4842-4476-0 / 9781484244760 |
Haben Sie eine Frage zum Produkt? |
Größe: 5,0 MB
DRM: Digitales Wasserzeichen
Dieses eBook enthält ein digitales Wasserzeichen und ist damit für Sie personalisiert. Bei einer missbräuchlichen Weitergabe des eBooks an Dritte ist eine Rückverfolgung an die Quelle möglich.
Dateiformat: PDF (Portable Document Format)
Mit einem festen Seitenlayout eignet sich die PDF besonders für Fachbücher mit Spalten, Tabellen und Abbildungen. Eine PDF kann auf fast allen Geräten angezeigt werden, ist aber für kleine Displays (Smartphone, eReader) nur eingeschränkt geeignet.
Systemvoraussetzungen:
PC/Mac: Mit einem PC oder Mac können Sie dieses eBook lesen. Sie benötigen dafür einen PDF-Viewer - z.B. den Adobe Reader oder Adobe Digital Editions.
eReader: Dieses eBook kann mit (fast) allen eBook-Readern gelesen werden. Mit dem amazon-Kindle ist es aber nicht kompatibel.
Smartphone/Tablet: Egal ob Apple oder Android, dieses eBook können Sie lesen. Sie benötigen dafür einen PDF-Viewer - z.B. die kostenlose Adobe Digital Editions-App.
Zusätzliches Feature: Online Lesen
Dieses eBook können Sie zusätzlich zum Download auch online im Webbrowser lesen.
Buying eBooks from abroad
For tax law reasons we can sell eBooks just within Germany and Switzerland. Regrettably we cannot fulfill eBook-orders from other countries.
aus dem Bereich