作者:empty 页数:655 出版社:empty |
Spring Cloud provides tools for developers to quickly build some of the common patternsin distributed systems(e.g.configuration management, service discovery, circuitbreakers, intelligent routing, micro-proxy, control bus) .Coordination of distributedsystems leads to boilerplate patterns, and using Spring Cloud developers can quicklystandup services and applications that implement those patterns.They will work well inany distributed environment, including the developer'sown laptop, bare metal datacentres, and managed platforms such as Cloud Foundry.Version:Finchley.SR 1
1.FeaturesSpring Cloud focuses on providing good out of box experience for typical use cases andexten sibi ity mechanism to cover others.Part I.Cloud Native ApplicationsCloud Native is a style of application development that encourages easy adoption ofbestpractices in the areas of continuous delivery and value-driven development.Arelated discipline is that of building 12-factor Applications, in which developmentpractices are aligned with delivery and operations goals—for instance, by usingdeclarative programming and management and monitoring.Spring Cloud facilitatesthese styles of development in a number of specific ways.The starting point is a set offeatures to which all components in a distributed system need easy access.Many of those features are covered by Spring Boot, on which Spring Cloud builds.Somemore features are delivered by Spring Cloud as two libraries:Spring Cloud Context andSpring Cloud Commons.Spring Cloud Context provides u tities and special services forthe ApplicationContext of a Spring Cloud application(bootstrap context, encryption,refresh scope, and environment endpoints) .Spring Cloud Commons is a set ofabstractions and common classes used in different Spring Cloud implementations(suchas Spring Cloud Netflix and Spring Cloud Consul) .If you get an exception due to I legal key size and you use Sun's JDK, you need toinstall the Java Cryptography Extension(JCE) Unlimited Strength Jurisdiction PolicyFiles.See the following links for more information:Extract the files into the JDK/jr eib/security folder for whichever version of JRE/JDKx 64/x 86 you use.2.Spring Cloud Context:ApplicationContext ServicesSpring Boot has an opinionated view of howto build an application with Spring.Forinstance, it has conventional locations for common configuration files and has endpointsfor common management and monitoring tasks.Spring Cloud builds on top of that andadds a few features that probably all components in a system would use or occasionallyneed,
2.1 The Bootstrap ApplicationContextA Spring Cloud application operates by creating a bootstrap context, which is a parentcontext for the main application.It is responsible for loading configuration propertiesfrom the external sources and for decrypting properties in the local external configurationfiles.The two contexts share an Environment, which is the source of external propertiesfor any Spring application.By default, bootstrap properties(not bootstrap.properties but properties that are loaded during the bootstrap phase)are added with high precedence, so they can not be overridden by local configuration.The bootstrap context uses a different convention for locating external configuration thanthe main applicationcontext.Instead of application.yml(or.properties) , you canuse bootstrap.yml, keeping the external configuration for bootstrap and main contextnicely separate.The following listing shows an example:bootstrap.yml.
目录
Spring Clud
1.Features.
Part I.Clud Native Applicatins.
Part I.Spring Clud Cnfi.
2.Spring Clud Cntext:ApplicatinCntext Service.
2.1 The Btstrap ApplicatinCntext
2.2 ApplicatinCntext Hierarchies
2.3 Changing the Lcatin f Btstrap Prperties.
2.4 verriding the Values f Remte Prperties.
2.5 Custmizing the Btstrap Cnfigu rati.
2.6 Custmizing the Btstrap Prperty Surces.
2.7 Lgging Cnfiguratin.
2.8 Envirnment Changes.
2.9 Refresh Scpe.
2.10 Encryptin and Decryptin.
2.11 Endpints
3.Spring Clud Cmmns:Cmmn Abstractins.
3.1@Enable Discvery Client.
3.2 Service Registry.
3.6 Spring Web Flux WebClient as a LadBalancer Clien.
13.2 Prpagating the Security Cntext r Using Spring Scpes.
3.1.1 Health Indicatr.
3.9.1 Feature types
3.9.2 Declaring features.
10.8.1 Health Indicatr.
3.2.1 Service Registry Aut-Registratin
3.2.2 Service Registry Actuatr Endpint.
3.3 Spring Rest Template as a LadBalancer Client.
3.4 Spring WebClient as a LadBalancer Client
3.4.1Re trying Failed Requests
3.5 Multiple Rest Template bjects
3.7 Ignre Netwrk Interfaces.
3.8 HTTPClient Factries
3.9 Enabled Features
4.QuickStart.
4.1 ClientSide Usage
5.Spring Clud Cnfig Server.
5.1 Envirnment Repsitry.
5.1.1Git Backend
5.1.2 Versin Cntrl Backend Filesystem Use.
5.1.3 FileSystem Backend.
5.1.4Vault Backend.
5.1.5 Accessing Backends Thrugh a Prxy
5.2 Health Indicatr.
5.1.6 Sharing Cnfiguratin With All Applicatins
5.1.7JDBC Backend.
5.1.8 Cmpsite Envirnment Repsitries.
5.1.9 Prperty verrides.
5.3 Security
5.4 Encryptin and Decryptin1.
5.5Key Management.
5.6 Creating a KeyStre fr Testing
5.7 Using Multiple Keys and Key Rtatin.
5.8 Serving Encrypted Prperties
6.Serving Alternative Frmats.
7.Serving PlainText
8.Embedding the Cnfig Server.
9.Push Ntificatins and Spring Clud Bu.
10.Spring Clud Cnfig Client
10.1 Cnfig First Btstrap
10.2 Discvery First Btstrap.
10.3 Cnfig Client Fail Fast.
10.4 Cnfig Client Retry.
10.5 Lcating Remte Cnfiguratin Resurces.
10.6 Specifying Multiple Urls fr the Cnfig Serve.
10.7 Cnfiguring Read Timeuts.
10.8 Security
Part II.Spring Clud Netflix
10.8.2 Prviding A Custm Rest Template.
10.8.3Vault.
10.9NestedKeysInVault
11.Service Discvery:Eureka Clients.
11.1Hw t Include Eureka Client
11.2 Registering with Eureka
11.3 Authenticating with the Eureka Server
11.4 Status Page and Health Indicatr.
11.5 Registering a Secure Applicatin.
11.6 Eureka's Health Checks.
11.7 Eureka Metadata fr Instances and Clients.
11.7.1 Using Eureka n Clud Fundry
11.7.2UsingEurekanAWS
11.8 Using the Eureka Client.
11.9 Alternatives t the Native Netflix Eureka Client
11.7.3 Changing the Eureka Instance ID
11.8.1 Eureka Client withut Jersey.
11.10WhyIsItsSlw t Register a Service?.
11.11Znes.
12.Service Discvery:Eureka Serve.
12.1Hw t Include Eureka Server.
12.2HwtRuna Eureka Server
12.3 High Availability, Znes and Regin.
12.4 Standalne Mde
12.5Peer Awareness
12.6 When t Prefer IPAddress.
12.7 Securing The Eureka Server
13.Circuit Breaker:Hystrix Clients.
13.1Hw t Include Hystrix
13.3 Health Indicatr.
13.4Hystrix Metrics Stream.
14.Circuit Breaker:Hystrix Dashbard
15.Hystrix Timeuts And Ribbn Clients.
15.1Hw t Include the Hystrix Dashbard.
15.2 Turbine.
16.ClientSide LadBalancer:Ribbn.
16.3 Custmizing the Default fr All Ribbn Clients.
15.2.1 Clusters Endpint.
15.3 Turbine Stream.
16.1Hw t Include Ribbn.
16.2 Custmizing the Ribbn Client
26.5.1 Durability
27.5.2 Reactive Surces.
16.4 Custmizing the Ribbn Client by Setting Prperties.
16.5 Using Ribbn with Eureka.
16.6 Example:Hwt Use Ribbn Withut Eur ek.
16.7 Example:Disable Eureka Use in Ribbn.
16.8 Using the Ribbn API Directly.
16.9 Caching f Ribbn Cnfiguratin.
16.10Hw t Cnfigure Hystrix ThreadPl.
16.11Hw t Prvide a Key t Ribbn'sIR ul.
17.External Cnfiguratin:Arch a i us
18.Ruter and Filter:Zu ul.
18.1HwtIncludeZuul.
18.2EmbeddedZuul Reverse Prxy.
18.3Zuul HttpClient
18.4 Ckies and Sensitive Headers.
18.5lgnred Headers,
18.6 Management Endpint.
18.6.1 Rutes Endpint.
18.6.2 Filters Endpint
18.7 Strangulatin Patterns and Lcal Frwards
18.8 Uplading Files thrugh Zu u.
18.9 QueryString Encding.
18.10PlainEmbeddedZuul.
18.11DisableZuul Filters
18.12 Prviding Hystrix Fallbacks Fr Rutes.
18.13Zuul Timeuts
18.14Rewriing the Lcatin header
18.15 Metrics
18.16Zuul Develper Guide.
18.16.1TheZuul Servlet.
18.16.2Zuul Request Cntext.
18.16.3@Enable zu ul Prxy vs.@enable zu ul Server
18.16.8ZuulEager ApplicatinCntext Lading.
23.1 Creating a Sample Applicatin by Using Spring Initial i zr.
23.2 Imprting the Prject int Yu rIDE
23.3 Adding a Message Handler, Building, and Running.
24.2.1 Bth Actuatr and Web Dependencies Are Nw ptinal.
24.2.2 Cntent-type Negtiatin Imprvements
24.3 Ntable Deprecatin s.
24.3.1Java Serializatin(Java Native and K ry)
24.3.2 Deprecated Classes and Methds.
26.Main Cncepts.
26.1 Applicatin Mdel.
26.1.1FatJAR
26.3 Persistent Publish-Subscribe Supprt.
26.6 Partitining Supprt
27.1 Destinatin Binders._
27.2 Destinatin Bindings.
27.3.1 Spring Integratin Supprt
27.3.2 Using@Stream Listener Anntatin.
27.4 Errr Handling.
18.16.4@Enable Zu ul Server Filters.
18.16.5@Enable Zu ul Prxy Filters.
18.16.6CustmZuul Filter Examples.
18.16.7HwZuul Errrs Wrk.
19.Plyglt supprt with Sidecar
20.Retrying Failed Requests.
20.1 Back ff Plicies.
20.2 Cnfiguratin.
20.2.1Zuul.
21.HTTP Clients
Part IV.Spring Clud pen Feign.
22.Declarative REST Client:Feign.
22.1Hw t Include Feign.
22.2 verriding Feign Defaults
22.3 Creating Feign Clients Manually.1.
22.4FeignHystrix Supprt
22.5FeignHystrix Fallbacks.
22.6Feign and@Primary.
22.7Feign Inheritance Supprt.
22.8Feign request/respnse cmpressin.
22.9Feign lgging
Part V.Spring Clud Stream.
23.QuickStart.
24.What's New in 2.0?
24.1 New Features and Cmpnents.
24.2 Ntable Enhancements.
25.Intrducing Spring Clud Stream
26.2 The Binder Abstractin
26.4 Cnsumer Grups.
26.5 Cnsumer Types.
27.Prgramming Mdel
27.3 Prducing and Cnsuming Messages.
27.3.3 Using@Stream Listener fr Cntent-based ruting.
27.3.4 Using Plled Cnsumers.
27.4.1 Applicatin Errr Handling.
27.4.2 System Errr Handling
27.4.3Retry Template.
27.5 Reactive Prgramming Supprt
27.5.1 Reactr-based Handlers.
28.1 Prducers and Cnsumers.
28.2BinderSPI
28.3 Binder Detectin.
28.3.1 Classpath Detectin.
28.4 Multiple Binders n the Classpath
28.5 Cnnecting t Multiple Systems.
28.6 Binding visualizatin and cntrl
28.7 Binder Cnfiguratin Prperties
29.Cnfiguratin ptins
29.1 Binding Service Prperties.
29.2 Binding Prperties.
31.1.1Schema Registry Client Prperties
29.2.1 Cmmn Binding Prperties.
29.2.2 Cnsumer Prperties.
29.2.3 Prducer Prperties
29.3 Using Dynamically Bund Destinatins.
30.CntentType Negtiatin.
30.1 Mechanics
30.1.1 CntentType versus Argument Type.
30.1.2Mssage Cnverters
30.2 Prvided Message Cnverters
30.3 User-defined Message Cnverters.
31.Schema Evlutin Supprt.
31.1 Schema Registry Client
31.2Avr Schema Registry Client Message Cnverters
31.2.1Avr Schema Registry Message Cnverter Prperties.
31.3ApacheAvr Message Cnverters
31.4 Cnverters with Schema Supprt.
31.5 Schema Registry Server
31.5.1 Schema Registry Server APL
31.5.2 Using Cnfluent'sSchema Registry.
31.6 Schema Registratin and Reslutin
38.3.2 Time Windw prperties:
31.6.1 Schema Registratin Prcess(Serializatin) .
31.6.2 Schema Reslutin Prcess(Deserializatin.
32.Inter-Applicatin Cmmunicatin
32.1 Cnnecting Multiple Applicatin Instances.
32.2 Instance Index and Instance Cunt.
32.3 Partitining.
33.Testing.
33.1 Disabling the Test Binder Autcnfiguratin.
34.Health Indicatr.
37.Apache Kafka Binder.
37.3.1Kafka Binder Prperties
32.3.1 Cnfiguring utput Bindings fr Partitining.
32.3.2 Cnfiguring Input Bindings fr Partitining.
35.Metrics Emitter.
36.Samples.
36.1 Deplying Stream Applicatins n Clud Fundry.
Part VI.Binder Implementatins.
37.1 Usage
37.2ApacheKafka Binder verview.
37.3 Cnfiguratin ptins
Part VII.Spring Clud Bu.
37.3.2Kafka Cnsumer Prperties.
37.3.3Kafka Prducer Prperties.
37.3.4 Usage examples.
37.4 Errr Channels
37.5Kafka Metrics.
37.6Dead-Letter Tpic Prcessing.
37.7 Partitining with the Kafka Binder
38.Apache Kafka Streams Binder
38.1 Usage
38.2Kafka Streams Binder verview
38.2.1 Streams DSL
38.3 Cnfiguratin ptins
38.3.1Kafka Streams Prperties
38.4 Multiple Input Bindings.
38.5 Multiple utput Bindings(aka Branching) .
38.4.1 Multiple Input Bindings as a Sink
38.4.2 Multiple Input Bindings as a Prcess.
38.6 Message Cnversin
38.6.1 utbund serializatin.
38.7.1 Handling Deserializatin Exceptins
38.6.2 Inbund Deserializatin.
38.7 Errr Handling
38.8 Interactive Queries
39.3.3 Rabbit Prducer Prperties
38.7.2 Handling Nn-Deserializatin Exceptin.
38.9 Accessing the underlying Kafka Streams bject
39.Rabbit MQ Binder.
39.1 Usage
39.2RabbitMQ Binder verview.
39.3 Cnfiguratin ptins
39.3.1RabbitMQ Binder Prperties
39.3.2RabbitMQ Cnsumer Prperties.
39.4RetryWiththeRabbitMQ Binder.
39.7 Partitining with the Rabbit MQ Bin de.
39.4.1 Putting it All Tgether.
39.5 Errr Channels
39.6Dead-Letter Queue Prcessing.
39.6.1Nn-Partitined Destinatins.
39.6.2 Partitined Destinatins.
40.QuickStart.
41.Bus Endpints.
41.1Bus Refresh Endpint
41.2BusEnv Endpint.
42.Addressing an Instance
43.Addressing All Instances f a Service.
44.Service ID Must Be Unique.
45.Custmizing the Message Brker.
46.Tracing Bus Events
47.Bradcasting Yur wn Events
47.1 Registering events in custm packages.
Part VIII.Spring Clud Sleuth
48.Intrductin.
48.1 Terminlgy.
48.2 Purpse.
48.2.1 Distributed Tracing with Zip kin.
48.2.2 Visualizing errrs.
48.2.3 Distributed Tracing with Brave.
48.2.4 Live examples
48.2.5Lg crrelatin.
48.2.6 Prpagating Span Cntext.
48.3.1 nly Sleuth(lg crrelatin) .
50.1.1T racing.
50.1.2 Lcal Tracing.
52.1.1 Prefixed fields
52.1.2 Extracting a Prpagated Cntext
52.1.4 Implementing Prpagatin.
58.4.1 Custm extractr.
58.4.2 Reslving Expressins fr a Value
62.5.2 Handler Interceptr.
62.6.4 Travers n.
66.4.1 Using Ribbn.
48.3 Adding Sleuth t the Prject.
48.3.2SleuthwithZipkinviaHTTP
49.Additinal Resurces.
48.3.3SleuthwithZipkin ver Rabbit MQ r Kafka
50.Features
50.1 Intrductin t Brave
50.1.3 Custmizing Spans
52.1.3SharingspanIDs between Client and Server.
62.3.2 Manual Cmmand setting.
62.5.3Async Servlet supprt.
50.1.4 Implicitly Lking up the Current Spa.
50.1.5RPCt racing.
51.Sampling
51.1 Declarative sampling
51.2 Custm sampling
51.3 Sampling in Spring Clud Sleuth.
52.Prpagatin.
52.1 Prpagating extrafields
53.Current Tracing Cmpnent
54.Current Span.
54.1 Setting a span in scpe manually.
55.Instrumentatin.
56.Span lifecycle.
56.1 Creating and finishing spans
56.2 Cntinuing Spans.
56.3 Creating a Span with an explicit Parent.
57.Naming spans.
57.1@Span Name An nt at in.
57.2 tString() methd.
58.Managing Spans with Anntatins.
58.1 Ratinale
58.2 Creating New Spans
58.3 Cntinuing Spans
58.4 Advanced Tag Setting.
58.4.3 Using the tString() methd
59.Custmizatins.
59.1HTTP.
59.2T racing Filter.
59.3 Custm service name
59.4 Custmizatin f Reprted Span.
59.5Hst Lcatr.
60.Sending Spans t Zip kin
61.Zip kin Stream Span