Spring Microservices in Action / Edition 1

Spring Microservices in Action / Edition 1

by John Carnell
ISBN-10:
1617293989
ISBN-13:
9781617293986
Pub. Date:
07/06/2017
Publisher:
Manning
ISBN-10:
1617293989
ISBN-13:
9781617293986
Pub. Date:
07/06/2017
Publisher:
Manning
Spring Microservices in Action / Edition 1

Spring Microservices in Action / Edition 1

by John Carnell
$49.99
Current price is , Original price is $49.99. You
$49.99 
  • SHIP THIS ITEM
    Qualifies for Free Shipping
  • PICK UP IN STORE

    Your local store may have stock of this item.

  • SHIP THIS ITEM

    Temporarily Out of Stock Online

    Please check back later for updated availability.


Overview

Summary

Spring Microservices in Action teaches you how to build microservice-based applications using Java and the Spring platform.

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

About the technology

Microservices break up your code into small, distributed, and independent services that require careful forethought and design. Fortunately, Spring Boot and Spring Cloud simplify your microservice applications, just as the Spring Framework simplifies enterprise Java development. Spring Boot removes the boilerplate code involved with writing a REST-based service. Spring Cloud provides a suite of tools for the discovery, routing, and deployment of microservices to the enterprise and the cloud.

About the Book

Spring Microservices in Action teaches you how to build microservice-based applications using Java and the Spring platform. You'll learn to do microservice design as you build and deploy your first Spring Cloud application. Throughout the book, carefully selected real-life examples expose microservice-based patterns for configuring, routing, scaling, and deploying your services. You'll see how Spring's intuitive tooling can help augment and refactor existing applications with micro services.

What's Inside

  • Core microservice design principles
  • Managing configuration with Spring Cloud Config
  • Client-side resiliency with Spring, Hystrix, and Ribbon
  • Intelligent routing using Netflix Zuul
  • Deploying Spring Cloud applications

About the Reader

This book is written for developers with Java and Spring experience.

About the Author

John Carnell is a senior cloud engineer with twenty years of experience in Java.

Table of contents

  1. Welcome to the cloud, Spring
  2. Building microservices with Spring Boot
  3. Controlling your configuration with Spring Cloud configuration server
  4. On service discovery
  5. When bad things happen: client resiliency patterns with Spring Cloud and Netflix Hystrix
  6. Service routing with Spring Cloud and Zuul
  7. Securing your microservices
  8. Event-driven architecture with Spring Cloud Stream
  9. Distributed tracing with Spring Cloud Sleuth and Zipkin
  10. Deploying your microservices

Product Details

ISBN-13: 9781617293986
Publisher: Manning
Publication date: 07/06/2017
Edition description: 1st Edition
Pages: 384
Sales rank: 1,088,710
Product dimensions: 7.40(w) x 8.70(h) x 0.90(d)

About the Author

John Carnell is a senior cloud engineer with 20 years of Java experience.

Table of Contents

Preface xv

Acknowledgments xvii

About this book xix

About the author xxii

About the cover illustration xxiii

1 Welcome to the cloud, Spring 1

1.1 What's a microservice? 2

1.2 What is Spring and why is it relevant to microservices? 5

1.3 What you'll learn in this book 6

1.4 Why is this book relevant to you? 7

1.5 Building a microservice with Spring Boot 8

1.6 Why change the way we build applications? 12

1.7 What exactly is the cloud? 13

1.8 Why the cloud and microservices? 15

1.9 Microservices are more than writing the code 17

Core microservice development pattern 19

Microservice routing patterns 20

Microservice client resiliency patterns 21

Microservice security patterns 23

Microservice logging and tracing patterns 24

Microservice build/deployment patterns 25

1.10 Using Spring Cloud in building your microservices 26

Spring Boot 28

Spring Cloud Config 28

Spring Cloud service discovery 28

Spring Cloud/Netflix Hystrix and Ribbon 29

Spring Cloud/Netflix Zuul 29

Spring Cloud Stream 29

Spring Cloud Sleuth 29

Spring Cloud Security 30

What about provisioning? 30

1.11 Spring Cloud by example 30

1.12 Making sure our examples are relevant 33

1.13 Summary 33

2 Building microservices with Spring Boot 35

2.1 The architect's story: designing the microservice architecture 38

Decomposing the business problem 38

Establishing service granularity 41

Talking to one another: service interfaces 43

2.2 When not to use microservices 44

Complexity of building distributed systems 44

Server sprawl 44

Type of application 44

Data transformations and consistency 45

2.3 The developer's tale: building a microservice with Spring Boot and Java 45

Getting started with the skeleton project 46

Booting your Spring Boot application: writing the Bootstrap class 47

Building the doorway into the microservice: the Spring Boot controller 48

2.4 The DevOps story: building for the rigors of runtime 53

Service assembly: packaging and deploying your microservices 56

Service bootstrapping: managing configuration of your microservices 58

Service registration and discovery: how clients communicate with your microservices 59

Communicating a microservice's health 60

2.5 Pulling the perspectives together 62

2.6 Summary 63

3 Controlling your configuration with Spring Cloud configuration server 64

3.1 On managing configuration (and complexity) 65

Your configuration management architecture 67

Implementation choices 69

3.2 Building our Spring Cloud configuration server 70

Setting up the Spring Cloud Config Bootstrap class 74

Using Spring Cloud configuration server with the filesystem 75

3.3 Integrating Spring Cloud Config with a Spring Boot client 77

Setting up the licensing service Spring Cloud Config server dependencies 79

Configuring the licensing service to use Spring Cloud Config 79

Wiring in a data source using Spring Cloud configuration server 83

Directly Reading Properties using the @Value Annotation 86

Using Spring Cloud configuration server with Git 87

Refreshing your properties using Spring Cloud configuration server 88

3.4 Protecting sensitive configuration information 89

Download and install Oracle JCE jars needed for encryption 90

Setting up an encryption key 91

Encrypting and decrypting a property 91

Configure microservices to use encryption on the client side 93

3.5 Closing thoughts 95

3.6 Summary 95

4 On service discovery 96

4.1 Where's my service? 97

4.2 On service discovery in the cloud 100

The architecture of service discovery 100

Service discover in action using Spring and Netflix Eureka 103

4.3 Building your Spring Eureka Service 105

4.4 Registering services with Spring Eureka 107

4.5 Using service discovery to look up a service 111

Looking up service instances with Spring DiscoveryClient 112

Invoking services with Ribbon-aware Spring RestTemplate 114

Invoking services with Netflix Feign client 116

4.6 Summary 118

5 When bad things happen: client resiliency patterns with Spring Cloud and Netflix Hystrix 119

5.1 What are client-side resiliency patterns? 120

Client-side load balancing 121

Circuit breaker 122

Fallback processing 122

Bulkheads 122

5.2 Why client resiliency matters 123

5.3 Enter Hystrix 126

5.4 Setting up the licensing server to use Spring Cloud and Hystrix 127

5.5 Implementing a circuit breaker using Hystrix 128

Timing out a call to the organization microservice 131

Customizing the timeout on a circuit breaker 132

5.6 Fallback processing 133

5.7 Implementing the bulkhead pattern 136

5.8 Getting beyond the basics; fine-tuning Hystrix 138

Hystrix configuration revisited 142

5.9 Thread context and Hystrix 144

ThreadLocal and Hystrix 144

The HystrixConcurrencyStrategy in action 147

5.10 Summary 151

6 Service routing with Spring Cloud and Zuul 153

6.1 What is a services gateway? 154

6.2 Introducing Spring Cloud and Netflix Zuul 157

Setting up the Zuul Spring Boot project 157

Using Spring Cloud annotation for the Zuul service 157

Configuring Zuul to communicate with Eureka 158

6.3 Configuring routes in Zuul 159

Automated mapping routes via service discovery 159

Mapping routes manually using service discovery 161

Manual mapping of routes using static URLs 165

Dynamically reload route configuration 168

Zuul and service timeouts 169

6.4 The real power of Zuul: filters 169

6.5 Building your first Zuul pre-filter generating correlation IDs 173

Using the correlation ID in your service calls 176

6.6 Building a post filter receiving correlation IDs 182

6.7 Building a dynamic route filter 184

Building the skeleton of the routing filter 186

Implementing the run() method 187

Forwarding the route 188

Pulling it all together 190

6.8 Summary 191

7 Securing your microservices 192

7.1 Introduction to OAuth2 193

7.2 Starting small: using Spring and OAuth2 to protect a single endpoint 195

Setting up the EagleEye OAuth2 authentication service 196

Registering client applications with the OAuth2 service 197

Configuring EagleEye users 200

Authenticating the user 202

7.3 Protecting the organization service using OAuth2 205

Adding the Spring Security and OAuth2 jars to the individual service 205

Configuring the service to point to your OAuth2 authentication service 206

Defining who and what can access the service 207

Propagating the OAuth2 access token 210

7.4 JavaScript Web Tokens and OAuth2 213

Modifying the authentication service to issue JavaScript Web Tokens 214

Consuming JavaScript Web Tokens in your microservices 218

Extending the JWT Token 220

Parsing a custom field out of a JavaScript token 222

7.5 Some closing thoughts on microservice security 224

7.6 Summary 227

8 Event-driven architecture with Spring Cloud Stream 228

8.1 The case for messaging, EDA, and microservices 229

Using synchronous request-response approach to communicate state change 230

Using messaging to communicate state changes between services 233

Downsides of a messaging architecture 235

8.2 Introducing Spring Cloud Stream 236

The Spring Cloud Stream architecture 237

8.3 Writing a simple message producer and consumer 238

Writing the message producer in the organization service 239

Writing the message consumer in the licensing service 244

Seeing the message service in action 247

8.4 A Spring Cloud Stream use case: distributed caching 249

Using Redis to cache lookups 250

Defining custom channels 256

Bringing it all together: clearing the cache when a message is received 257

8.5 Summary 258

9 Distributed tracing with Spring Cloud Sleuth and Zipkin 259

9.1 Spring Cloud Sleuth and the correlation ID 260

Adding Spring Cloud sleuth to licensing and organization 261

Anatomy of a Spring Cloud Sleuth trace 262

9.2 Log aggregation and Spring Cloud Sleuth 263

A Spring Cloud Sleuth/Papertrail implementation in action 265

Create a Papertrail account and configure a syslog connector 267

Redirecting Docker output to Papertrail 268

Searching for Spring Cloud Sleuth trace IDs in Papertrail 270

Adding the correlation ID to the HTTP response with Zuul 272

9.3 Distributed tracing with Open Zipkin 274

Setting up the Spring Cloud Sleuth and Zipkin dependencies 275

Configuring the services to point to Zipkin 275

Installing and configuring a Zipkin server 276

Selling tracing levels 278

Using Zipkin to trace transactions 278

Visualizing a more complex transaction 281

Capturing messaging traces 282

Adding custom spans 284

9.4 Summary 287

10 Deploying your microservices 288

10.1 EagleEye: setting up your core infrastructure in the cloud 290

Creating the PostgreSQL database using Amazon EDS 293

Creating the Redis cluster in Amazon 296

Creating an ECS cluster 298

10.2 Beyond the infrastructure: deploying EagleEye 302

Deploying the EagleEye services to ECS manually 303

10.3 The architecture of a build/deployment pipeline 305

10.4 Your build and deployment pipeline in action 309

103 Beginning your build deploy/pipeline: GitHub and Travis CI 311

10.6 Enabling your service to build in Travis CI 312

Core build run-time configuration 315

Pre-build tool installations 318

Executing the build 320

Tagging the source control code 320

Building the microservices and creating the Docker images 321

Pushing the images to Docker Hub 322

Starting the services in Amazon ECS 323

Kicking off the platform tests 323

10.7 Closing thoughts on the build/deployment pipeline 325

10.8 Summary 325

Appendix A Running a cloud on your desktop 327

Appendix B OAuth2 grant types 336

Index 345

From the B&N Reads Blog

Customer Reviews