《Spring Microservices in Action》(Manning 2016)中文版目录

目 录

1. 欢迎来到Cloud和Spring                                        1

1.1什么是微服务?                                                          2

1.2什么是Spring,它和微服务有什么关联?                                    5

1.3你将从这本书里学到什么?                                                 6

1.4为什么这本书与你有关?                                                   7

1.5使用Spring Boot构建一个微服务                                           8

1.6为什么要改变我们构建应用程序的方式?                                     12

1.7云究竟是什么?                                                          13

1.8为什么是云和微服务?                                                     15

1.9微服务不仅仅是编写代码                                                   19

  1.9.1微服务核心开发模式                                      19

  1.9.2微服务路由模式                                          20

  1.9.3微服务客户端弹性模式                                    21

  1.9.4微服务安全模式                                          23

  1.9.5微服务日志记录和跟踪模式                                24

  1.9.6微服务构建和部署模式                                    25

1.10使用Spring Cloud构建微服务                                            26

  1.10.1 Spring Boot                                            28

  1.10.2 Spring Cloud Config                                    28

  1.10.3 Spring Cloud Service Discovery                          28

  1.10.4 Spring Cloud/Netflix Hystrix andRibbon                 29

  1.10.5 Spring Cloud/Netflix Zuul                                29

  1.10.6 Spring Cloud Stream                                     29

  1.10.7 Spring Cloud Sleuth                                      29

  1.10.8 Spring Cloud Security                                    30

  1.10.9 准备些什么?                                             30

1.11使用Spring Cloud举例                                                 30

1.12了解与我们相关的例子                                                    33

1.13小结                                                                   33

2. 使用SpringBoot构建微服务                                     35

2.1架构师的故事:设计微服务架构                                             38

  2.1.1分解业务问题                                             38

  2.1.2确定服务粒度                                             41

  2.1.3互相交谈:服务接口                                       43

2.2什么时候不使用微服务                                                    44

  2.2.1分布式系统构建的复杂性                                   44

  2.2.2服务器扩展                                               44

  2.2.3应用类型                                                44

  2.2.4数据转换和一致性                                         45

2.3开发:使用Spring Boot和Java构建一个微服务                              45

   2.3.1从骨架项目快速入门                                      46

   2.3.2编写引导类,启动你的Spring Boot应用                     47

   2.3.3创建微服务的访问入口:Spring Boot控制器                48

2.4运维:严格的运行时构建                                                   53

  2.4.1服务装配:打包和部署微服务                               56

  2.4.2服务引导:管理微服务的配置                               58

  2.4.3服务注册与发现:客户端如何与微服务通信                   59

  2.4.4监控微服务健康状况                                       60

2.5观点汇总                                                               62

2.6小结                                                                   63

3. 使用SpringCloud Configuration Server控制配置               64

3.1管理配置(和复杂性)                                                   65

  3.1.1配置管理架构                                             67

  3.1.2实现选择                                                69

3.2建立Spring Cloud Config Server                                         70

  3.2.1创建Spring Cloud配置引导类                             74

  3.2.2通过配置文件使用Spring CloudConfig Server               75

3.3将Spring Cloud配置与Spring Boot客户端集成                            77

  3.3.1配置Spring Cloud Config Server的依赖                    79

  3.3.2 Spring Cloud Config使用配置                            79

  3.3.3使用Spring Cloud ConfigurationServer配置数据源        83

  3.3.4使用@Value注解直接读取属性                             86

  3.3.5通过Git使用Spring Cloud Config Server                  87

  3.3.6通过Spring Cloud Config Server刷新属性                 88

3.4保护敏感配置信息                                                     89

  3.4.1下载和安装加密所需的Oracle JCE JAR包                   90

  3.4.2配置加密密钥                                            91

  3.4.3加密和解密属性                                          91

  3.4.4配置微服务使用加密的客户端                              93

3.5最后的思考                                                             95

3.6小结                                                                   95

4. 服务发现                                                      96

4.1我的服务在哪里?                                                       97

4.2关于云端服务发现的研究                                                100

  4.2.1服务发现架构                                             100

  4.2.2使用Spring和Netflix Eureka实现服务发现                  103

4.3创建Spring Eureka Service                                              105

4.4使用Spring Eureka注册服务                                             107

4.5使用服务发现查找服务                                                  111

  4.5.1使用SpringDiscoveryClient查找服务实例                   112

  4.5.2使用Ribbon-aware SpringRestTemplate调用服务           114

  4.5.3使用Netflix Feign client调用服务                           116

4.6小结                                                                  118

5. 坏事发生时:使用Spring Cloud和Netflix Hystrix的客户端弹性模式119

5.1客户端的弹性模式                                                       120

  5.1.1客户端负载均衡                                            121

  5.1.2断路器                                                   122

  5.1.3回退处理                                                 122

  5.1.4舱壁                                                     122

5.2客户端弹性的重要性                                                    123

5.3熔断机制                                                              126

5.4配置使用Spring Cloud和Hystrix的依赖                                 127

5.5使用Hystrix实现断路器                                                 128

  5.5.1调用微服务超时                                            131

  5.5.2自定义断路器上的超时时间                                  132

5.6回退处理                                                               133

5.7舱壁模式的实现                                                         136

5.8深入理解Hystrix                                                        138

  5.8.1进一步理解Hystrix配置                                     142

5.9线程上下文和Hystrix                                                    144

  5.9.1 ThreadLocal 和 Hystrix                                    144

  5.9.2 Hystrix并发策略                                           147

5.10小结                                                                  151

6. 使用SpringCloud和Zuul进行服务路由                          153

6.1服务网关                                                               154

6.2 SpringCloud和Netflix Zuul                                             157

  6.2.1配置Spring Boot工程引用Zuul依赖                          157

  6.2.2使用SpringCloud注解配置Zuul服务                         157

  6.2.3配置Zuul与Eureka通信                                     158

6.3在Zuul中配置路由                                                      159

  6.3.1通过服务发现自动映射路由                                   159

  6.3.2通过服务发现手动映射路由                                   161

  6.3.3使用静态URL手动映射路由                                  165

  6.3.4动态重新加载路由配置                                       168

  6.3.5 Zuul和服务超时                                            169

6.4 Zuul过滤器                                                            169

6.5创建pre类型Zuul过滤器生成关联ID                                       173

  6.5.1在服务调用中使用关联ID                                    176

6.6创建post类型Zuul过滤器接收关联ID                                      182

6.7创建动态路由过滤器                                                      184

  6.7.1构建路由过滤器的框架                                       186

  6.7.2实现run方法                                              187

  6.7.3转发路由                                                   188

  6.7.4把代码整合在一起                                           190

6.8小结                                                                   191

7. 微服务安全                                                    192

7.1介绍OAuth2                                                           193

7.2从小事做起:使用Spring和OAuth2保护一个单独的端点                    195

  7.2.1配置EagleEye OAuth2认证服务                              196

  7.2.2在OAuth2服务注册客户端应用                              197

  7.2.3配置EagleEye用户                                          200

  7.2.4用户认证                                                   202

7.3使用OAuth2保护组织服务                                               205

  7.3.1为单独的服务添加SpringSecurity和OAuth2 JAR包           205

  7.3.2配置服务指向OAuth2认证服务                            206

  7.3.3定义那些资源可以访问服务                                   207

  7.3.4传递OAuth2访问令牌                                       210

7.4 JavaScriptWeb Tokens和OAuth2                                       213

  7.4.1修改认证服务来发布JavaScriptWeb Tokens                   214

  7.4.2在微服务中消费JavaScript WebTokens                       218

  7.4.3扩展JWT Token                                            220

  7.4.4解析来自自定义字段的JavaScripttoken                        222

7.5关于微服务安全的思考                                                  224

7.6小结                                                                  227

8. Spring Cloud Stream的事件驱动架构                           228

8.1 消息,EDA和微服务的案例                                              229

  8.1.1使用同步请求响应的方法传递状态改变                         230

  8.1.2在服务之间使用消息传递状态改变                             233

  8.1.3消息架构的缺点                                             235

8.2介绍Spring Cloud Stream                                              236

  8.2.1 Spring Cloud Stream体系结构                              237

8.3 写一个简单的消息生产者和消费者                                         238

  8.3.1在组织服务中编写消息生产者                                 239

  8.3.2在许可服务中编写消息消费者                                 244

  8.3.3查看运行中的消息服务                                       247

8.4 SpringCloud Stream使用案例:分布式缓存                               249

  8.4.1使用Redis缓存查找                                         250

  8.4.2定义自定义channels                                        256

  8.4.3将它们放在一起:收到消息时清除缓存                         257

8.5小结                                                                  258

9. 使用SpringCloud Sleuth和Zipkin进行分布式跟踪              259

9.1 SpringCloud Sleuth和关联ID                                           260

  9.1.1添加Spring Cloud Sleuth                                    261

  9.1.2分析Spring Cloud Sleuth Trace                              262

9.2日志聚合和Spring Cloud Sleuth                                         263

  9.2.1 实战中的Spring Cloud Sleuth/Papertrail实现               265

  9.2.2创建一个Papertrail账户并配置syslog连接器                 267

  9.2.3将Docker输出重定向到Papertrail                          268

  9.2.4在Papertrail里搜索Spring Cloud Sleuth TraceID             270

  9.2.5使用Zuul将关联ID添加到HTTP响应中                      272

9.3使用Zipkin实现分布式跟踪                                             274

  9.3.1配置Spring Cloud Sleuth和Zipkin依赖                     275

  9.3.2配置服务指向Zipkin                                       275

  9.3.3安装和配置Zipkin Server                                   276

  9.3.4设置跟踪级别                                              278

  9.3.5使用Zipkin跟踪交易                                       278

  9.3.6可视化更复杂的交易                                        281

  9.3.7捕获消息跟踪                                              282

  9.3.8添加自定义span                                           284

9.4小结                                                                  287

10. 部署微服务                                                  288

10.1 EagleEye:在云环境中设置核心基础设施                                 290

  10.1.1使用Amazon RDS创建PostgreSQL数据库                  293

  10.1.2在Amazon创建Redis集群                                296

  10.1.3创建ECS(弹性可伸缩的计算服务)集群                     298

10.2除了基础设施:部署EagleEye                                  302

  10.2.1在ECS中手动部署EagleEye服务                           303

10.3构建/部署管道的架构                                                  305

10.4构建和部署管道                                                      309

10.5开始你的构建/部署管道:GitHub和Travis CI                            311

10.6在Travis CI中构建服务                                               312

  10.6.1核心构建运行时配置                                       315

  10.6.2安装预构建工具                                           318

  10.6.3执行构建                                                 320

  10.6.4标记源代码控制代码                                       320

  10.6.5构建微服务和创建Docker镜像                             321

  10.6.6将镜像发布到Docker Hub                                 322

  10.6.7在Amazon ECS环境中启动服务                            323

  10.6.8开展平台测试                                             323

10.7关于构建/部署管道的总结                                              325

10.8小结                                                                325

附录A:在桌面上运行云                                          327

附录B:OAuth2授权类型                                        336

你可能感兴趣的:(微服务)