The book titled "Spring Cloud and Docker microservices architecture in action"-Li, which was completed in 2017-01-12, was written with the spring Cloud play Micro service architecture. Many friends want to first look at the source code, is now released.
The code released this time:
- A total of 70 + Demo
- Covers Eureka, Ribbon, Feign, Hystrix, Zuul, Spring Cloud Config, Spring Cloud Bus, Spring Cloud Sleuth, Docker, Docker compose, and more.
Chapter 1-11 Code Address:
- Https://github.com/itmuch/spring-cloud-docker-microservice-book-code
- Http://git.oschina.net/itmuch/spring-cloud-docker-microservice-book-code
12-14 chapter Supporting code address:
- Https://github.com/itmuch/spring-cloud-docker-microservice-book-code-docker
- Http://git.oschina.net/itmuch/spring-cloud-docker-microservice-book-code-docker
Book catalogue
See: http://www.itmuch.com/advertisment/my-spring-book/
Copyright notice
This document is licensed by the CC by 3.0 CN protocol. may be freely reproduced, quoted, but must be signed by the author and indicate the source of the article. If reprinted to the public number, please add the author public number QR code at the end of the text.
Follow me
Blog: http://www.itmuch.com
Related Skill Tree:
1th. Basic Knowledge 1
What is microservices architecture 1
--the difference from the monomer system 1
--How to implement micro-service 2
Why Choose Spring Cloud 6
Introduction to Spring Cloud 7
Release Notes 8
2nd Micro-Service Build: Spring Boot 11
Introduction to the Framework 12
Quick Start 13
--Project construction and analysis 13
--Implementing RESTful API 17
Configuration detailed 20
--Configuration file 20
--Custom parameter 22
--Parameter Reference 22
--Use random number 23
--command line parameter 23
--Multi-environment configuration 24
--Load Order 25
Monitoring and Management 26
--First acquaintance actuator 27
--Native Endpoint 28
Summary 38
3rd. Service governance: Spring Cloud Eureka 39
Service Governance 39
--Netflix Eureka 40
--Building Service Registration Center 41
--Registered service provider 43
--Highly Available registry 46
--service discovery and consumption 48
Eureka Detailed 51
--Basic Architecture 52
--Service governance mechanism 52
--Source Code Analysis 56
Configuration Detailed 65
--Service Registration class configuration 65
--Service Instance class configuration 67
Cross-platform Support 71
4th Client Load Balancing: Spring Cloud Ribbon 73
Client Load Balancing 73
Resttemplate detailed 75
--GET Request 75
--POST Request 77
--Put request 79
--Delete Request 79
SOURCE Analysis 80
--Load Balancer 91
--Load Balancing Strategy 109
Configuration Detailed 123
--Automation Configuration 124
--Camden version optimized for ribbonclient configuration 125
--Parameter Configuration 127
--Combined with Eureka 127
Retry Mechanism 128
5th. Service-Tolerant protection: Spring Cloud hystrix 130
Quick Start 131
Principle Analysis 135
--Workflow 135
--Circuit Breaker principle 144
--dependent Isolation 148
Using the detailed 151
--Create Request command 151
--Define Service demotion 154
--Exception Handling 157
--command name, grouping, and thread pool partitioning 158
--Request Cache 159
--Request a merger 166
Attribute Details 172
--Command attribute 174
--Collapser attribute 184
--ThreadPool attribute 185
Hystrix instrument Panel 187
Turbine Cluster monitoring 192
--building monitoring aggregation services 192
--combined with the message agent 196
6th. Declarative service invocation: Spring Cloud Feign 199
Quick Start 200
Parameter Binding 202
Inheritance features 205
Ribbon Configuration 209
Global Configuration 209
Specifying service Configuration 209
Retry Mechanism 210
Hystrix Configuration 211
Global Configuration 211
Disable Hystrix 211
specifying command Configuration 212
Service downgrade Configuration 212
Other configuration 214
7th. API Gateway Service: Spring Cloud Zuul 217
Quick Start 219
--Building the Gateway 220
--Request Routing 221
--Request Filtering 223
Route Details 226
--Traditional routing configuration 226
--Service Routing configuration 228
--Default rule for service routing 229
--Custom route mapping rules 229
--Path Matching 230
--Route prefix 233
--Local Jump 234
--Cookie and header information 235
--Hystrix and ribbon support 236
Filter detailed 238
--Filter 238
--Request life cycle 239
--Core Filter 240
--Exception handling 244
--Disable Filter 256
Dynamic Loading 257
--Dynamic routing 257
--Dynamic Filter 261
8th Distributed Configuration Center: Spring Cloud Config 267
Quick Start 267
--Build Configuration Center 268
--Detailed configuration rules 269
--Client Configuration mapping 272
Service 274
--Basic Architecture 274
--Git Configuration repository 276
--SVN Configuration Warehouse 279
--Local Warehouse 279
--Local file system 279
--Health Monitoring 280
--Property Overrides 281
--Security 281
--Encryption and decryption 282
--Highly available configuration 286
Customer's Solution 286
--URI Specifies the configuration center 287
--Service-oriented configuration center 287
--Failure quick response and retry 290
--Get Remote configuration 292
--Dynamic Refresh configuration 293
9th message bus: Spring Cloud bus 295
Message Agent 295
RABBITMQ Implementing message Bus 296
--Basic Concept 297
--Installation and use 298
--Quick Start 302
--Integrated spring Cloud Bus 306
--Principle Analysis 307
--Specify the Refresh range 308
--Architecture Optimization 309
--RABBITMQ Configuration 310
Kafka implementing message Bus 312
--Kafka Introduction 312
--Quick Start 313
--Integrated spring Cloud Bus 315
--Kafka Configuration 318
Deep Understanding 318
--Source Code Analysis 320
--Support for other message agents 342
10th message-driven microservices: Spring Cloud Stream 344
Quick Start 344
Core Concept 349
--Binder 350
--Publish-Subscribe mode 351
--consumer group 353
--Message partition 354
Using the detailed 355
--Turn on bind function 355
--binding Message channel 356
--news production and consumption 360
--Responsive programming 366
--consumer group and message partition 368
--Message Type 370
Binder Details 373
--Binder SPI 373
--Automation Configuration 374
--Multi-binder configuration 374
--RABBITMQ and Kafka bindings 376
Configuration Detailed 376
--Basic Configuration 377
--Binding channel configuration 377
--Binder Configuration 379
11th. Distributed Service tracking: Spring Cloud Sleuth 386
Quick Start 386
--Preparation Work 386
--Implementation Tracking 389
Tracking Principle 390
Sampling Collection 392
Integration with Logstash 394
Integration with Zipkin 397
--HTTP collection 398
--Message Middleware collection 402
--Collection Principle 404
--Data storage 414
--API Interface 417
Appendix A Starter POMs 419
PostScript 421
1 Micro-Service Architecture Overview .................................................... 1
1.1 Problems with monolithic application architectures 1
1.2 How to solve the problem of single application architecture 3
1.3 What is Micro service 3
1.4 Advantages and challenges of the MicroServices architecture 5
Advantages of the 1.4.1 MicroServices architecture 5
1.4.2 Micro-Service Architecture challenges 5
1.5 micro-Service design principles 6
1.6 How to implement micro-service Architecture 7
1.6.1 Technology Selection 7
1.6.2 frame composition and common components 8
2 Micro-service development Framework--spring Cloud ................................... 10
2.1 Spring Cloud Introduction 10
2.2 Spring Cloud features 10
2.3 Spring Cloud Version 11
2.3.1 Version Introduction 11
2.3.2 Sub-project list 12
2.3.3 Spring cloud/spring Boot version compatibility 13
3 start using spring Cloud Combat Micro Service .................................. 14
3.1 Spring Cloud Combat Premise 14
3.1.1 Technical Reserve 14
3.1.2 Tools and software version 15
3.2 Service providers and service consumers 16
3.3 Authoring Service Providers 16
3.3.1 Manually writing a project 17
3.3.2 using spring INITIALIZR to quickly create a spring Boot project 21
3.4 Writing Service Consumers 23
3.5 Integrating Spring Boot Actuator 25 for the project
3.6 What are the hard-coded issues 27
4 Micro-Service registration and Discovery .................................................. 29
4.1 Service Discovery Introduction 29
4.2 Eureka Introduction 31
4.3 Eureka principle 31
4.4 Writing Eureka Server 33
4.5 Registering a microservices on Eureka Server 35
4.6 High Availability of Eureka Server 36
4.6.1 registering an app on a Eureka Server cluster 38
4.7 Adding user authentication for Eureka Server 39
4.7.1 registering MicroServices with Eureka Server 40 to be certified
4.8 Understanding metadata for Eureka 41
4.8.1 Retrofit User micro-service 41
4.8.2 Transformation Film Micro Service 41
4.9 Eureka Server's Rest endpoint 43
4.9.1 Example 45
4.9.2 Logoff micro-service instance 49
4.10 Eureka Self-protection mode 51
IP Selection in 4.11 multi-NIC Environments 52
4.11.1 ignoring a network card with the specified name 52
4.11.2 using regular expressions, specify the network address to use 52
4.11.3 Use only site-local address 53
4.11.4 manually specifying an IP address 53
Health check of 4.12 Eureka 53
5 Client side Load balancing is implemented using the Ribbon ................................. 56
5.1 Ribbon Introduction 56
5.2 Integration of the Ribbon 57 for service consumers
5.3 Customizing Ribbon configuration with Java code 60
5.4 Customizing Ribbon configuration with Properties 63
5.5 Detach Eureka using Ribbon 64
6 using feign to implement declarative rest calls ................................... 66
6.1 Feign Introduction 67
6.2 Integrating feign for service consumers 67
6.3 Customizing the Feign configuration 69
6.4 Creating feign manually 72
6.4.1 Modifying a user's micro-service 72
6.4.2 Modifying the movie Micro Service 76
6.5 Feign support for inheritance 78
6.6 Feign support for compression 79
6.7 Feign's Log 80
6.8 using feign to construct a multi-parameter request 82
6.8.1 GET request multi-parameter URL 82
6.8.2 POST Request contains multiple parameters 83
7 using Hystrix to implement fault-tolerant processing of microservices ................................. 85
7.1 means to implement fault tolerance 85
7.1.1 Avalanche Effect 85
7.1.2 how to fault tolerance 86
7.2 Using Hystrix for fault tolerance 88
7.2.1 Hystrix Introduction 88
7.2.2 Universal Way Integration Hystrix 89
Condition monitoring and in-depth understanding of 7.2.3 Hystrix Circuit Breaker 91
7.2.4 Hystrix thread Isolation policy and propagation context 93
7.2.5 Feign using Hystrix 96
Monitoring of 7.3 Hystrix 101
Hystrix monitoring of the 7.3.1 feign project 102
7.4 Visualizing monitoring data using Hystrix Dashboard 103
7.5 Aggregating monitoring data using turbine 105
7.5.1 Turbine Introduction 105
7.5.2 monitoring multiple microservices with turbine 105
7.5.3 collecting data using message Middleware 108
8 Building a microservices gateway using Zuul .......................................... 113
8.1 Why to use the MicroServices Gateway 113
8.2 Zuul Introduction 115
8.3 Writing Zuul micro-service Gateway 115
8.4 Routing Endpoint for Zuul 118
8.5 Zuul routing configuration in detail 119
8.6 Zuul's safety and header 122
8.6.1 settings for sensitive headers 122
8.6.2 Ignore header 123
8.7 Uploading files using Zuul 124
8.7.1 writing a file upload micro-service 124
8.8 Zuul Filter 127
8.8.1 filter type and request life cycle 127
8.8.2 Writing Zuul Filter 128
8.8.3 Disabling the Zuul filter 130
8.9 Zuul fault-tolerant and fallback 130
8.9.1 add fallback for Zuul 131
8.10 Zuul High-availability 133
The 8.10.1 Zuul client is also registered on the Eureka Server 133
8.10.2 Zuul Client not registered on Eureka Server 133
8.11 Integrating non-JVM microservices with sidecar 134
8.11.1 writing node. js microservices 135
8.11.2 writing sidecar 136
8.11.3 Sidecar's Endpoint 138
8.11.4 Sidecar and node. JS microservices Separation Deployment 139
8.11.5 Sidecar Principle Analysis 139
9 Unified management of microservices configuration using spring Cloud Config ...................... . 142
9.1 Why unified Management of MicroServices configuration 142
9.2 Spring Cloud Config Introduction 143
9.3 Writing config Server 144
9.3.1 Config Server Endpoint 145
9.4 Writing config Client 147
9.5 config Server git repository configuration detailed 149
9.6 Config Server health status indicator 152
9.7 Encryption and decryption of configuration content 153
9.7.1 Installing JCE 153
9.7.2 Config Server Plus decryption endpoint 153
9.7.3 Symmetric Encryption 153
9.7.4 Storage of encrypted content 154
9.7.5 Asymmetric Encryption 155
9.8 Manually refreshing the configuration using the/refresh endpoint 155
9.9 Automatic refresh of configuration using spring Cloud Bus 157
9.9.1 Spring Cloud Bus Introduction 157
9.9.2 Automatic Refresh 158
9.9.3 Partial Refresh 159
9.9.4 Architecture Improvements 159
9.9.5 Trace Bus Event 160
9.10 Spring Cloud Config works with Eureka 161
9.11 user authentication for Spring Cloud Config 162
9.11.1 Config Client connection requires user-authenticated config Server 163
High availability of 9.12 Config Server 164
9.12.1 High availability of Git repositories 164
9.12.2 RabbitMQ High-availability 164
9.12.3 Config Server itself is highly available 165
10 micro-service tracking with spring Cloud sleuth ............................ 167
10.1 Why to implement micro-service tracking 167
10.2 Spring Cloud Sleuth Introduction 168
10.3 Integrating spring Cloud Sleuth 170
10.4 Spring Cloud Sleuth works with Elk 172
10.5 Spring Cloud Sleuth works with Zipkin 176
10.5.1 Zipkin Introduction 176
10.5.2 Writing Zipkin Server 176
10.5.3 Micro-service Integration Zipkin 178
10.5.4 collecting data using message middleware 181
10.5.5 Storing trace Data 183
Spring Cloud FAQ and Summary ....................................... 186
11.1 Eureka FAQ 186
11.1.1 Eureka Registration Service 186 slower
11.1.2 stopped micro service node logoff slow or no logoff 187
11.1.3 How to customize instance ID 188 for MicroServices
Summary and solution of unknown problem of 11.1.4 Eureka 189
11.2 Hystrix/feign first request failed after consolidating Hystrix 190
11.2.1 Cause Analysis 191
11.2.2 Solution 191
11.3 Turbine aggregated data not complete 191
11.3.1 Solution 192
11.4 Spring Cloud Components Configuration Properties 193
11.4.1 Spring Cloud Configuration 193
11.4.2 Native Configuration 193
11.5 Spring Cloud Location Problem Summary 194
Getting Started with Docker ...................................................... . . 197
12.1 Docker Introduction 197
12.2 Docker Architecture 197
12.3 Installing Docker 199
12.3.1 System Requirements 199
12.3.2 Removing unofficial Packages 199
12.3.3 Setting the Yum source 199
12.3.4 mounting Dokcer 200
12.3.5 Uninstalling Docker 201
12.4 Configuring the Image Accelerator 201
12.5 Docker Common Commands 202
12.5.1 Docker Image Common Commands 202
12.5.2 Docker Container Common commands 204
13 running microservices on Docker .......................................... 209
13.1 Building a Docker image using Dockerfile 209
13.1.1 Dockerfile Common Instructions 210
13.1.2 building an image using Dockerfile 215
13.2 managing Docker images with Docker Registry 217
13.2.1 using Docker Hub to manage images 217
13.2.2 using a private warehouse to manage images 219
13.3 Building a Docker image using the Maven plugin 220
13.3.1 Quick Start 221
13.3.2 plug-in read dockerfile for build 222
13.3.3 binding a plug-in to a phase execution 223
13.3.4 Push Image 224
13.4 FAQ and Summary 226
14 using Docker Compose to orchestrate microservices ................................... 227
14.1 Docker Compose Introduction 227
14.2 Installing Docker Compose 227
14.2.1 mounting Compose 228
14.2.2 Installing the Compose command completion tool 228
14.3 Docker Compose Quick Start 229
14.3.1 Basic Steps 229
14.3.2 Getting Started example 229
14.3.3 Engineering, services, containers 230
14.4 Docker-compose.yml Common Commands 230
14.4.1 Build 230
14.4.2 Command 231
14.4.3 DNS 231
14.4.4 Dns_search 231
14.4.5 Environment 231
14.4.6 Env_file 232
14.4.7 expose 232
14.4.8 External_links 232
14.4.9 Image 232
14.4.10 Links 232
14.4.11 Networks 233
14.4.12 Network_mode 233
14.4.13 Ports 233
14.4.14 volumes 233
14.4.15 Volumes_from 234
14.5 docker-compose Common Commands 234
14.5.1 Build 234
14.5.2 Help 235
14.5.3 Kill 235
14.5.4 Logs 235
14.5.5 Port 235
14.5.6 PS 235
14.5.7 Pull 235
14.5.8 RM 236
14.5.9 Run 236
14.5.10 Scale 236
14.5.11 Start 236
14.5.12 Stop 236
14.5.13 up 236
14.6 Docker Compose Network Settings 237
14.6.1 Basic Concepts 237
14.6.2 Update Container 237
14.6.3 Links 238
14.6.4 Specifying a custom network 238
14.6.5 Configuring the default network 239
14.6.6 using an existing network 239
14.7 Integrated Combat: Orchestrate Spring Cloud microservices with Docker Comose 240
14.7.1 Orchestration Spring Cloud microservices 240
14.7.2 orchestration of Highly available Eureka Server 243
14.7.3 orchestrate highly available spring Cloud microservices clusters and dynamic scaling 245
14.8 FAQ and Summary 247
Https://item.jd.com/12168358.html
The "Spring Cloud and Docker microservices Architecture Combat" companion code