Spring Cloud


Table of Contents

1. Features
I. Cloud Native Applications
2. Spring Cloud Context: Application Context Services
2.1. The Bootstrap Application Context
2.2. Application Context Hierarchies
2.3. Changing the Location of Bootstrap Properties
2.4. Overriding the Values of Remote Properties
2.5. Customizing the Bootstrap Configuration
2.6. Customizing the Bootstrap Property Sources
2.7. Environment Changes
2.8. Refresh Scope
2.9. Encryption and Decryption
2.10. Endpoints
3. Spring Cloud Commons: Common Abstractions
3.1. @EnableDiscoveryClient
3.1.1. Health Indicator
3.2. ServiceRegistry
3.2.1. ServiceRegistry Auto-Registration
3.2.2. Service Registry Actuator Endpoint
3.3. Spring RestTemplate as a Load Balancer Client
3.3.1. Retrying Failed Requests
3.3.2. Multiple RestTemplate objects
3.4. Spring WebFlux WebClient as a Load Balancer Client
3.5. Ignore Network Interfaces
3.6. HTTP Client Factories
II. Spring Cloud Config
4. Quick Start
4.1. Client Side Usage
5. Spring Cloud Config Server
5.1. Environment Repository
5.1.1. Git Backend
Placeholders in Git URI
Pattern Matching and Multiple Repositories
Authentication
Authentication with AWS CodeCommit
Git SSH configuration using properties
Placeholders in Git Search Paths
Force pull in Git Repositories
5.1.2. Version Control Backend Filesystem Use
5.1.3. File System Backend
5.1.4. Vault Backend
Multiple Properties Sources
5.1.5. Sharing Configuration With All Applications
File Based Repositories
Vault Server
5.1.6. JDBC Backend
5.1.7. Composite Environment Repositories
Custom Composite Environment Repositories
5.1.8. Property Overrides
5.2. Health Indicator
5.3. Security
5.4. Encryption and Decryption
5.5. Key Management
5.6. Creating a Key Store for Testing
5.7. Using Multiple Keys and Key Rotation
5.8. Serving Encrypted Properties
6. Serving Alternative Formats
7. Serving Plain Text
8. Embedding the Config Server
9. Push Notifications and Spring Cloud Bus
10. Spring Cloud Config Client
10.1. Config First Bootstrap
10.2. Discovery First Bootstrap
10.3. Config Client Fail Fast
10.4. Config Client Retry
10.5. Locating Remote Configuration Resources
10.6. Security
10.6.1. Health Indicator
10.6.2. Providing A Custom RestTemplate
10.6.3. Vault
10.7. Vault
10.7.1. Nested Keys In Vault
III. Spring Cloud Netflix
11. Service Discovery: Eureka Clients
11.1. How to Include Eureka Client
11.2. Registering with Eureka
11.3. Authenticating with the Eureka Server
11.4. Status Page and Health Indicator
11.5. Registering a Secure Application
11.6. Eureka’s Health Checks
11.7. Eureka Metadata for Instances and Clients
11.7.1. Using Eureka on Cloudfoundry
11.7.2. Using Eureka on AWS
11.7.3. Changing the Eureka Instance ID
11.8. Using the EurekaClient
11.8.1. EurekaClient without Jersey
11.9. Alternatives to the native Netflix EurekaClient
11.10. Why is it so Slow to Register a Service?
11.11. Zones
12. Service Discovery: Eureka Server
12.1. How to Include Eureka Server
12.2. How to Run a Eureka Server
12.3. High Availability, Zones and Regions
12.4. Standalone Mode
12.5. Peer Awareness
12.6. Prefer IP Address
13. Circuit Breaker: Hystrix Clients
13.1. How to Include Hystrix
13.2. Propagating the Security Context or using Spring Scopes
13.3. Health Indicator
13.4. Hystrix Metrics Stream
14. Circuit Breaker: Hystrix Dashboard
15. Hystrix Timeouts And Ribbon Clients
15.1. How to Include Hystrix Dashboard
15.2. Turbine
15.3. Turbine Stream
16. Client Side Load Balancer: Ribbon
16.1. How to Include Ribbon
16.2. Customizing the Ribbon Client
16.3. Customizing default for all Ribbon Clients
16.4. Customizing the Ribbon Client using properties
16.5. Using Ribbon with Eureka
16.6. Example: How to Use Ribbon Without Eureka
16.7. Example: Disable Eureka use in Ribbon
16.8. Using the Ribbon API Directly
16.9. Caching of Ribbon Configuration
16.10. How to Configure Hystrix thread pools
16.11. How to Provide a Key to Ribbon’s IRule
17. Declarative REST Client: Feign
17.1. How to Include Feign
17.2. Overriding Feign Defaults
17.3. Creating Feign Clients Manually
17.4. Feign Hystrix Support
17.5. Feign Hystrix Fallbacks
17.6. Feign and @Primary
17.7. Feign Inheritance Support
17.8. Feign request/response compression
17.9. Feign logging
18. External Configuration: Archaius
19. Router and Filter: Zuul
19.1. How to Include Zuul
19.2. Embedded Zuul Reverse Proxy
19.3. Zuul Http Client
19.4. Cookies and Sensitive Headers
19.5. Ignored Headers
19.6. Management Endpoints
19.6.1. Routes Endpoint
19.6.2. Filters Endpoint
19.7. Strangulation Patterns and Local Forwards
19.8. Uploading Files through Zuul
19.9. Query String Encoding
19.10. Plain Embedded Zuul
19.11. Disable Zuul Filters
19.12. Providing Hystrix Fallbacks For Routes
19.13. Zuul Timeouts
19.14. Rewriting Location header
19.15. Zuul Developer Guide
19.15.1. The Zuul Servlet
19.15.2. Zuul RequestContext
19.15.3. @EnableZuulProxy vs. @EnableZuulServer
19.15.4. @EnableZuulServer Filters
19.15.5. @EnableZuulProxy Filters
19.15.6. Custom Zuul Filter examples
19.15.7. How to Write a Pre Filter
19.15.8. How to Write a Route Filter
19.15.9. How to Write a Post Filter
19.15.10. How Zuul Errors Work
19.15.11. Zuul Eager Application Context Loading
20. Polyglot support with Sidecar
21. Metrics: Spectator, Servo, and Atlas
21.1. Dimensional vs. Hierarchical Metrics
21.2. Default Metrics Collection
21.3. Metrics Collection: Spectator
21.3.1. Spectator Counter
21.3.2. Spectator Timer
21.3.3. Spectator Gauge
21.3.4. Spectator Distribution Summaries
21.4. Metrics Collection: Servo
21.4.1. Creating Servo Monitors
21.5. Metrics Backend: Atlas
21.5.1. Global tags
21.5.2. Using Atlas
21.6. Retrying Failed Requests
21.6.1. BackOff Policies
21.6.2. Configuration
21.6.3. Zuul
22. HTTP Clients
IV. Spring Cloud Stream
23. Introducing Spring Cloud Stream
24. Main Concepts
24.1. Application Model
24.1.1. Fat JAR
24.2. The Binder Abstraction
24.3. Persistent Publish-Subscribe Support
24.4. Consumer Groups
24.4.1. Durability
24.5. Partitioning Support
25. Programming Model
25.1. Declaring and Binding Channels
25.1.1. Triggering Binding Via @EnableBinding
25.1.2. @Input and @Output
Customizing Channel Names
Source, Sink, and Processor
25.1.3. Accessing Bound Channels
Injecting the Bound Interfaces
Injecting Channels Directly
25.1.4. Producing and Consuming Messages
Native Spring Integration Support
Spring Integration Error Channel Support
Message Channel Binders and Error Channels
Using @StreamListener for Automatic Content Type Handling
Using @StreamListener for dispatching messages to multiple methods
25.1.5. Reactive Programming Support
Reactor-based handlers
RxJava 1.x support
Reactive Sources
25.1.6. Aggregation
Configuring aggregate application
Configuring binding service properties for non self contained aggregate application
26. Binders
26.1. Producers and Consumers
26.2. Binder SPI
26.3. Binder Detection
26.3.1. Classpath Detection
26.4. Multiple Binders on the Classpath
26.5. Connecting to Multiple Systems
26.6. Binder configuration properties
27. Configuration Options
27.1. Spring Cloud Stream Properties
27.2. Binding Properties
27.2.1. Properties for Use of Spring Cloud Stream
27.2.2. Consumer properties
27.2.3. Producer Properties
27.3. Using dynamically bound destinations
28. Content Type and Transformation
28.1. MIME types
28.2. Channel contentType and Message Headers
28.3. ContentType handling for output channels
28.4. ContentType handling for input channels
28.5. Customizing message conversion
28.6. @StreamListener and Message Conversion
29. Schema evolution support
29.1. Apache Avro Message Converters
29.2. Converters with schema support
29.3. Schema Registry Support
29.4. Schema Registry Server
29.4.1. Schema Registry Server API
POST /
GET /{subject}/{format}/{version}
GET /{subject}/{format}
GET /schemas/{id}
DELETE /{subject}/{format}/{version}
DELETE /schemas/{id}
DELETE /{subject}
29.5. Schema Registry Client
29.5.1. Using Confluent’s Schema Registry
29.5.2. Schema Registry Client properties
29.6. Avro Schema Registry Client Message Converters
29.6.1. Avro Schema Registry Message Converter properties
29.7. Schema Registration and Resolution
29.7.1. Schema Registration Process (Serialization)
29.7.2. Schema Resolution Process (Deserialization)
30. Inter-Application Communication
30.1. Connecting Multiple Application Instances
30.2. Instance Index and Instance Count
30.3. Partitioning
30.3.1. Configuring Output Bindings for Partitioning
Spring-managed custom PartitionKeyExtractorClass implementations
Configuring Input Bindings for Partitioning
31. Testing
31.1. Disabling the test binder autoconfiguration
32. Health Indicator
33. Metrics Emitter
34. Samples
35. Getting Started
35.1. Deploying Stream applications on CloudFoundry
V. Binder Implementations
36. Apache Kafka Binder
36.1. Usage
36.2. Apache Kafka Binder Overview
36.3. Configuration Options
36.3.1. Kafka Binder Properties
36.3.2. Kafka Consumer Properties
36.3.3. Kafka Producer Properties
36.3.4. Usage examples
Example: Setting autoCommitOffset false and relying on manual acking.
Example: security configuration
Using the binder with Apache Kafka 0.10
Excluding Kafka broker jar from the classpath of the binder based application
36.4. Kafka Streams Binding Capabilities of Spring Cloud Stream
36.4.1. Usage example of high level streams DSL
36.4.2. Support for interactive queries
36.4.3. Kafka Streams properties
36.5. Error Channels
36.6. Kafka Metrics
36.7. Dead-Letter Topic Processing
37. RabbitMQ Binder
37.1. Usage
37.2. RabbitMQ Binder Overview
37.3. Configuration Options
37.3.1. RabbitMQ Binder Properties
37.3.2. RabbitMQ Consumer Properties
37.3.3. Rabbit Producer Properties
37.4. Retry With the RabbitMQ Binder
37.4.1. Overview
37.4.2. Putting it All Together
37.5. Error Channels
37.6. Dead-Letter Queue Processing
37.6.1. Non-Partitioned Destinations
37.6.2. Partitioned Destinations
republishToDlq=false
republishToDlq=true
VI. Spring Cloud Bus
38. Quick Start
39. Addressing an Instance
40. Addressing all instances of a service
41. Service ID must be unique
42. Customizing the Message Broker
43. Tracing Bus Events
44. Broadcasting Your Own Events
44.1. Registering events in custom packages
VII. Spring Cloud Sleuth
45. Introduction
45.1. Terminology
45.2. Purpose
45.2.1. Distributed tracing with Zipkin
45.2.2. Visualizing errors
45.2.3. Live examples
45.2.4. Log correlation
JSON Logback with Logstash
45.2.5. Propagating Span Context
Baggage vs. Span Tags
45.3. Adding to the project
45.3.1. Only Sleuth (log correlation)
45.3.2. Sleuth with Zipkin via HTTP
45.3.3. Sleuth with Zipkin via RabbitMQ or Kafka
46. Additional resources
47. Features
48. Sampling
49. Instrumentation
50. Span lifecycle
50.1. Creating and closing spans
50.2. Continuing spans
50.3. Creating spans with an explicit parent
51. Naming spans
51.1. @SpanName annotation
51.2. toString() method
52. Managing spans with annotations
52.1. Rationale
52.2. Creating new spans
52.3. Continuing spans
52.4. More advanced tag setting
52.4.1. Custom extractor
52.4.2. Resolving expressions for value
52.4.3. Using toString method
53. Customizations
53.1. Spring Integration
53.2. HTTP
53.3. Example
53.4. TraceFilter
53.5. Custom SA tag in Zipkin
53.6. Custom service name
53.7. Customization of reported spans
53.8. Host locator
54. Sending spans to Zipkin
55. Span Data as Messages
55.1. Zipkin Consumer
55.2. Custom Consumer
56. Metrics
57. Integrations
57.1. Runnable and Callable
57.2. Hystrix
57.2.1. Custom Concurrency Strategy
57.2.2. Manual Command setting
57.3. RxJava
57.4. HTTP integration
57.4.1. HTTP Filter
57.4.2. HandlerInterceptor
57.4.3. Async Servlet support
57.4.4. WebFlux support
57.5. HTTP client integration
57.5.1. Synchronous Rest Template
57.5.2. Asynchronous Rest Template
Multiple Asynchronous Rest Templates
57.5.3. WebClient
57.5.4. Traverson
57.6. Feign
57.7. Asynchronous communication
57.7.1. @Async annotated methods
57.7.2. @Scheduled annotated methods
57.7.3. Executor, ExecutorService and ScheduledExecutorService
Customization of Executors
57.8. Messaging
57.9. Zuul
58. Running examples
VIII. Spring Cloud Consul
59. Install Consul
60. Consul Agent
61. Service Discovery with Consul
61.1. How to activate
61.2. Registering with Consul
61.3. HTTP Health Check
61.3.1. Metadata and Consul tags
61.3.2. Making the Consul Instance ID Unique
61.4. Looking up services
61.4.1. Using Ribbon
61.4.2. Using the DiscoveryClient
62. Distributed Configuration with Consul
62.1. How to activate
62.2. Customizing
62.3. Config Watch
62.4. YAML or Properties with Config
62.5. git2consul with Config
62.6. Fail Fast
63. Consul Retry
64. Spring Cloud Bus with Consul
64.1. How to activate
65. Circuit Breaker with Hystrix
66. Hystrix metrics aggregation with Turbine and Consul
IX. Spring Cloud Zookeeper
67. Install Zookeeper
68. Service Discovery with Zookeeper
68.1. How to activate
68.2. Registering with Zookeeper
68.3. Using the DiscoveryClient
69. Using Spring Cloud Zookeeper with Spring Cloud Netflix Components
69.1. Ribbon with Zookeeper
70. Spring Cloud Zookeeper and Service Registry
70.1. Instance Status
71. Zookeeper Dependencies
71.1. Using the Zookeeper Dependencies
71.2. How to activate Zookeeper Dependencies
71.3. Setting up Zookeeper Dependencies
71.3.1. Aliases
71.3.2. Path
71.3.3. Load balancer type
71.3.4. Content-Type template and version
71.3.5. Default headers
71.3.6. Obligatory dependencies
71.3.7. Stubs
71.4. Configuring Spring Cloud Zookeeper Dependencies
72. Spring Cloud Zookeeper Dependency Watcher
72.1. How to activate
72.2. Registering a listener
72.3. Presence Checker
73. Distributed Configuration with Zookeeper
73.1. How to activate
73.2. Customizing
73.3. ACLs
X. Spring Cloud Security
74. Quickstart
74.1. OAuth2 Single Sign On
74.2. OAuth2 Protected Resource
75. More Detail
75.1. Single Sign On
75.2. Token Relay
75.2.1. Client Token Relay
75.2.2. Client Token Relay in Zuul Proxy
75.2.3. Resource Server Token Relay
76. Configuring Authentication Downstream of a Zuul Proxy
XI. Spring Cloud for Cloud Foundry
77. Discovery
78. Single Sign On
XII. Spring Cloud Contract
79. Spring Cloud Contract
80. Spring Cloud Contract Verifier Introduction
80.1. Why a Contract Verifier?
80.1.1. Testing issues
80.2. Purposes
80.3. How It Works
80.3.1. Defining the contract
80.3.2. Client Side
80.3.3. Server Side
80.4. Step-by-step Guide to Consumer Driven Contracts (CDC)
80.4.1. Technical note
80.4.2. Consumer side (Loan Issuance)
80.4.3. Producer side (Fraud Detection server)
80.4.4. Consumer Side (Loan Issuance) Final Step
80.5. Dependencies
80.6. Additional Links
80.6.1. Spring Cloud Contract video
80.6.2. Readings
80.7. Samples
81. Spring Cloud Contract FAQ
81.1. Why use Spring Cloud Contract Verifier and not X ?
81.2. What is this value(consumer(), producer()) ?
81.3. How to do Stubs versioning?
81.3.1. API Versioning
81.3.2. JAR versioning
81.3.3. Dev or prod stubs
81.4. Common repo with contracts
81.4.1. Repo structure
81.4.2. Workflow
81.4.3. Consumer
81.4.4. Producer
81.5. Can I have multiple base classes for tests?
81.6. How can I debug the request/response being sent by the generated tests client?
81.6.1. How can I debug the mapping/request/response being sent by WireMock?
81.6.2. How can I see what got registered in the HTTP server stub?
81.6.3. Can I reference the request from the response?
81.6.4. Can I reference text from file?
82. Spring Cloud Contract Verifier Setup
82.1. Gradle Project
82.1.1. Prerequisites
82.1.2. Add Gradle Plugin with Dependencies
82.1.3. Gradle and Rest Assured 2.0
82.1.4. Snapshot Versions for Gradle
82.1.5. Add stubs
82.1.6. Run the Plugin
82.1.7. Default Setup
82.1.8. Configure Plugin
82.1.9. Configuration Options
82.1.10. Single Base Class for All Tests
82.1.11. Different Base Classes for Contracts
82.1.12. Invoking Generated Tests
82.1.13. Spring Cloud Contract Verifier on the Consumer Side
82.2. Maven Project
82.2.1. Add maven plugin
82.2.2. Maven and Rest Assured 2.0
82.2.3. Snapshot versions for Maven
82.2.4. Add stubs
82.2.5. Run plugin
82.2.6. Configure plugin
82.2.7. Configuration Options
82.2.8. Single Base Class for All Tests
82.2.9. Different base classes for contracts
82.2.10. Invoking generated tests
82.2.11. Maven Plugin and STS
82.2.12. Spring Cloud Contract Verifier on the Consumer Side
82.3. Stubs and Transitive Dependencies
82.4. Scenarios
83. Spring Cloud Contract Verifier Messaging
83.1. Integrations
83.2. Manual Integration Testing
83.3. Publisher-Side Test Generation
83.3.1. Scenario 1: No Input Message
83.3.2. Scenario 2: Output Triggered by Input
83.3.3. Scenario 3: No Output Message
83.4. Consumer Stub Generation
84. Spring Cloud Contract Stub Runner
84.1. Snapshot versions
84.2. Publishing Stubs as JARs
84.3. Stub Runner Core
84.3.1. Retrieving stubs
Stub downloading
Classpath scanning
84.3.2. Running stubs
Limitations
Running using main app
HTTP Stubs
Viewing registered mappings
Messaging Stubs
84.4. Stub Runner JUnit Rule
84.4.1. Maven settings
84.4.2. Providing fixed ports
84.4.3. Fluent API
84.4.4. Stub Runner with Spring
84.5. Stub Runner Spring Cloud
84.5.1. Stubbing Service Discovery
Test profiles and service discovery
84.5.2. Additional Configuration
84.6. Stub Runner Boot Application
84.6.1. How to use it?
Stub Runner Server
Spring Cloud CLI
84.6.2. Endpoints
HTTP
Messaging
84.6.3. Example
84.6.4. Stub Runner Boot with Service Discovery
84.7. Stubs Per Consumer
84.8. Common
84.8.1. Common Properties for JUnit and Spring
84.8.2. Stub Runner Stubs IDs
85. Stub Runner for Messaging
85.1. Stub triggering
85.1.1. Trigger by Label
85.1.2. Trigger by Group and Artifact Ids
85.1.3. Trigger by Artifact Ids
85.1.4. Trigger All Messages
85.2. Stub Runner Integration
85.2.1. Adding the Runner to the Project
85.2.2. Disabling the functionality
Scenario 1 (no input message)
Scenario 2 (output triggered by input)
Scenario 3 (input with no output)
85.3. Stub Runner Stream
85.3.1. Adding the Runner to the Project
85.3.2. Disabling the functionality
Scenario 1 (no input message)
Scenario 2 (output triggered by input)
Scenario 3 (input with no output)
85.4. Stub Runner Spring AMQP
85.4.1. Adding the Runner to the Project
Triggering the message
Spring AMQP Test Configuration
86. Contract DSL
86.1. Limitations
86.2. Common Top-Level elements
86.2.1. Description
86.2.2. Name
86.2.3. Ignoring Contracts
86.2.4. Passing Values from Files
86.2.5. HTTP Top-Level Elements
86.3. Request
86.4. Response
86.5. Dynamic properties
86.5.1. Dynamic properties inside the body
86.5.2. Regular expressions
86.5.3. Passing Optional Parameters
86.5.4. Executing Custom Methods on the Server Side
86.5.5. Referencing the Request from the Response
86.5.6. Registering Your Own WireMock Extension
86.5.7. Dynamic Properties in the Matchers Sections
86.6. JAX-RS Support
86.7. Async Support
86.8. Working with Context Paths
86.9. Messaging Top-Level Elements
86.9.1. Output Triggered by a Method
86.9.2. Output Triggered by a Message
86.9.3. Consumer/Producer
86.9.4. Common
86.10. Multiple Contracts in One File
87. Customization
87.1. Extending the DSL
87.1.1. Common JAR
87.1.2. Adding the Dependency to the Project
87.1.3. Test the Dependency in the Project’s Dependencies
87.1.4. Test a Dependency in the Plugin’s Dependencies
87.1.5. Referencing classes in DSLs
88. Using the Pluggable Architecture
88.1. Custom Contract Converter
88.1.1. Pact Converter
88.1.2. Pact Contract
88.1.3. Pact for Producers
88.1.4. Pact for Consumers
88.2. Using the Custom Test Generator
88.3. Using the Custom Stub Generator
88.4. Using the Custom Stub Runner
88.5. Using the Custom Stub Downloader
89. Spring Cloud Contract WireMock
89.1. Registering Stubs Automatically
89.2. Using Files to Specify the Stub Bodies
89.3. Alternative: Using JUnit Rules
89.4. Relaxed SSL Validation for Rest Template
89.5. WireMock and Spring MVC Mocks
89.6. Generating Stubs using REST Docs
89.7. Generating Contracts by Using REST Docs
90. Migrations
90.1. 1.0.x → 1.1.x
90.1.1. New structure of generated stubs
90.2. 1.1.x → 1.2.x
90.2.1. Custom HttpServerStub
90.2.2. New packages for generated tests
90.2.3. New Methods in TemplateProcessor
90.2.4. RestAssured 3.0
90.3. 1.2.x → 2.0.x
90.3.1. No Camel support
91. Links
XIII. Spring Cloud Vault
92. Quick Start
93. Client Side Usage
93.1. Authentication
94. Authentication methods
94.1. Token authentication
94.2. AppId authentication
94.2.1. Custom UserId
94.3. AppRole authentication
94.4. AWS-EC2 authentication
94.5. AWS-IAM authentication
94.6. TLS certificate authentication
94.7. Cubbyhole authentication
94.8. Kubernetes authentication
95. Secret Backends
95.1. Generic Backend
95.2. Consul
95.3. RabbitMQ
95.4. AWS
96. Database backends
96.1. Database
96.2. Apache Cassandra
96.3. MongoDB
96.4. MySQL
96.5. PostgreSQL
97. Configure PropertySourceLocator behavior
98. Service Registry Configuration
99. Vault Client Fail Fast
100. Vault Client SSL configuration
101. Lease lifecycle management (renewal and revocation)
XIV. Appendix: Compendium of Configuration Properties