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.4. Multiple RestTemplate objects
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
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. Rewriting Location header
19.14. Zuul Developer Guide
19.14.1. The Zuul Servlet
19.14.2. Zuul RequestContext
19.14.3. @EnableZuulProxy vs. @EnableZuulServer
19.14.4. @EnableZuulServer Filters
19.14.5. @EnableZuulProxy Filters
19.14.6. Custom Zuul Filter examples
19.14.7. How to Write a Pre Filter
19.14.8. How to Write a Route Filter
19.14.9. How to Write a Post Filter
19.14.10. How Zuul Errors Work
19.14.11. Zuul Eager Application Context Loading
20. Polyglot support with Sidecar
21. RxJava with Spring MVC
22. Metrics: Spectator, Servo, and Atlas
22.1. Dimensional vs. Hierarchical Metrics
22.2. Default Metrics Collection
22.3. Metrics Collection: Spectator
22.3.1. Spectator Counter
22.3.2. Spectator Timer
22.3.3. Spectator Gauge
22.3.4. Spectator Distribution Summaries
22.4. Metrics Collection: Servo
22.4.1. Creating Servo Monitors
22.5. Metrics Backend: Atlas
22.5.1. Global tags
22.5.2. Using Atlas
22.6. Retrying Failed Requests
22.6.1. Configuration
22.6.2. Zuul
23. HTTP Clients
IV. Spring Cloud Stream
24. Introducing Spring Cloud Stream
25. Main Concepts
25.1. Application Model
25.1.1. Fat JAR
25.2. The Binder Abstraction
25.3. Persistent Publish-Subscribe Support
25.4. Consumer Groups
25.4.1. Durability
25.5. Partitioning Support
26. Programming Model
26.1. Declaring and Binding Channels
26.1.1. Triggering Binding Via @EnableBinding
26.1.2. @Input and @Output
Customizing Channel Names
Source, Sink, and Processor
26.1.3. Accessing Bound Channels
Injecting the Bound Interfaces
Injecting Channels Directly
26.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
26.1.5. Reactive Programming Support
Reactor-based handlers
RxJava 1.x support
Reactive Sources
26.1.6. Aggregation
Configuring aggregate application
Configuring binding service properties for non self contained aggregate application
27. Binders
27.1. Producers and Consumers
27.2. Binder SPI
27.3. Binder Detection
27.3.1. Classpath Detection
27.4. Multiple Binders on the Classpath
27.5. Connecting to Multiple Systems
27.6. Binder configuration properties
28. Configuration Options
28.1. Spring Cloud Stream Properties
28.2. Binding Properties
28.2.1. Properties for Use of Spring Cloud Stream
28.2.2. Consumer properties
28.2.3. Producer Properties
28.3. Using dynamically bound destinations
29. Content Type and Transformation
29.1. MIME types
29.2. MIME types and Java types
29.3. Customizing message conversion
29.4. @StreamListener and Message Conversion
30. Schema evolution support
30.1. Apache Avro Message Converters
30.2. Converters with schema support
30.3. Schema Registry Support
30.4. Schema Registry Server
30.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}
30.5. Schema Registry Client
30.5.1. Using Confluent’s Schema Registry
30.5.2. Schema Registry Client properties
30.6. Avro Schema Registry Client Message Converters
30.6.1. Avro Schema Registry Message Converter properties
30.7. Schema Registration and Resolution
30.7.1. Schema Registration Process (Serialization)
30.7.2. Schema Resolution Process (Deserialization)
31. Inter-Application Communication
31.1. Connecting Multiple Application Instances
31.2. Instance Index and Instance Count
31.3. Partitioning
31.3.1. Configuring Output Bindings for Partitioning
Spring-managed custom PartitionKeyExtractorClass implementations
Configuring Input Bindings for Partitioning
32. Testing
32.1. Disabling the test binder autoconfiguration
33. Health Indicator
34. Metrics Emitter
35. Samples
36. Getting Started
36.1. Deploying Stream applications on CloudFoundry
V. Binder Implementations
37. Apache Kafka Binder
37.1. Usage
37.2. Apache Kafka Binder Overview
37.3. Configuration Options
37.3.1. Kafka Binder Properties
37.3.2. Kafka Consumer Properties
37.3.3. Kafka Producer Properties
37.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
37.4. Kafka Streams Binding Capabilities of Spring Cloud Stream
37.4.1. Usage example of high level streams DSL
37.4.2. Support for interactive queries
37.4.3. Kafka Streams properties
37.5. Error Channels
37.6. Kafka Metrics
37.7. Dead-Letter Topic Processing
38. RabbitMQ Binder
38.1. Usage
38.2. RabbitMQ Binder Overview
38.3. Configuration Options
38.3.1. RabbitMQ Binder Properties
38.3.2. RabbitMQ Consumer Properties
38.3.3. Rabbit Producer Properties
38.4. Retry With the RabbitMQ Binder
38.4.1. Overview
38.4.2. Putting it All Together
38.5. Error Channels
38.6. Dead-Letter Queue Processing
38.6.1. Non-Partitioned Destinations
38.6.2. Partitioned Destinations
republishToDlq=false
republishToDlq=true
VI. Spring Cloud Bus
39. Quick Start
40. Addressing an Instance
41. Addressing all instances of a service
42. Application Context ID must be unique
43. Customizing the Message Broker
44. Tracing Bus Events
45. Broadcasting Your Own Events
45.1. Registering events in custom packages
VII. Spring Cloud Sleuth
46. Introduction
46.1. Terminology
46.2. Purpose
46.2.1. Distributed tracing with Zipkin
46.2.2. Visualizing errors
46.2.3. Live examples
46.2.4. Log correlation
JSON Logback with Logstash
46.2.5. Propagating Span Context
Baggage vs. Span Tags
46.3. Adding to the project
46.3.1. Only Sleuth (log correlation)
46.3.2. Sleuth with Zipkin via HTTP
46.3.3. Sleuth with Zipkin via RabbitMQ or Kafka
47. Additional resources
48. Features
49. Sampling
50. Instrumentation
51. Span lifecycle
51.1. Creating and closing spans
51.2. Continuing spans
51.3. Creating spans with an explicit parent
52. Naming spans
52.1. @SpanName annotation
52.2. toString() method
53. Managing spans with annotations
53.1. Rationale
53.2. Creating new spans
53.3. Continuing spans
53.4. More advanced tag setting
53.4.1. Custom extractor
53.4.2. Resolving expressions for value
53.4.3. Using toString method
54. Customizations
54.1. Spring Integration
54.2. HTTP
54.3. Example
54.4. TraceFilter
54.5. Custom SA tag in Zipkin
54.6. Custom service name
54.7. Customization of reported spans
54.8. Host locator
55. Sending spans to Zipkin
56. Span Data as Messages
56.1. Zipkin Consumer
56.2. Custom Consumer
57. Metrics
58. Integrations
58.1. Runnable and Callable
58.2. Hystrix
58.2.1. Custom Concurrency Strategy
58.2.2. Manual Command setting
58.3. RxJava
58.4. HTTP integration
58.4.1. HTTP Filter
58.4.2. HandlerInterceptor
58.4.3. Async Servlet support
58.5. HTTP client integration
58.5.1. Synchronous Rest Template
58.5.2. Asynchronous Rest Template
Multiple Asynchronous Rest Templates
58.5.3. Traverson
58.6. Feign
58.7. Asynchronous communication
58.7.1. @Async annotated methods
58.7.2. @Scheduled annotated methods
58.7.3. Executor, ExecutorService and ScheduledExecutorService
Customization of Executors
58.8. Messaging
58.9. Zuul
59. Running examples
VIII. Spring Cloud Consul
60. Install Consul
61. Consul Agent
62. Service Discovery with Consul
62.1. How to activate
62.2. Registering with Consul
62.3. HTTP Health Check
62.3.1. Metadata and Consul tags
62.3.2. Making the Consul Instance ID Unique
62.4. Looking up services
62.4.1. Using Ribbon
62.4.2. Using the DiscoveryClient
63. Distributed Configuration with Consul
63.1. How to activate
63.2. Customizing
63.3. Config Watch
63.4. YAML or Properties with Config
63.5. git2consul with Config
63.6. Fail Fast
64. Consul Retry
65. Spring Cloud Bus with Consul
65.1. How to activate
66. Circuit Breaker with Hystrix
67. Hystrix metrics aggregation with Turbine and Consul
IX. Spring Cloud Zookeeper
68. Install Zookeeper
69. Service Discovery with Zookeeper
69.1. How to activate
69.2. Registering with Zookeeper
69.3. Using the DiscoveryClient
70. Using Spring Cloud Zookeeper with Spring Cloud Netflix Components
70.1. Ribbon with Zookeeper
71. Spring Cloud Zookeeper and Service Registry
71.1. Instance Status
72. Zookeeper Dependencies
72.1. Using the Zookeeper Dependencies
72.2. How to activate Zookeeper Dependencies
72.3. Setting up Zookeeper Dependencies
72.3.1. Aliases
72.3.2. Path
72.3.3. Load balancer type
72.3.4. Content-Type template and version
72.3.5. Default headers
72.3.6. Obligatory dependencies
72.3.7. Stubs
72.4. Configuring Spring Cloud Zookeeper Dependencies
73. Spring Cloud Zookeeper Dependency Watcher
73.1. How to activate
73.2. Registering a listener
73.3. Presence Checker
74. Distributed Configuration with Zookeeper
74.1. How to activate
74.2. Customizing
74.3. ACLs
X. Spring Cloud Security
75. Quickstart
75.1. OAuth2 Single Sign On
75.2. OAuth2 Protected Resource
76. More Detail
76.1. Single Sign On
76.2. Token Relay
76.2.1. Client Token Relay
76.2.2. Client Token Relay in Zuul Proxy
76.2.3. Resource Server Token Relay
77. Configuring Authentication Downstream of a Zuul Proxy
XI. Spring Cloud for Cloud Foundry
78. Discovery
79. Single Sign On
XII. Spring Cloud Contract
80. Spring Cloud Contract
81. Spring Cloud Contract Verifier Introduction
81.1. Why a Contract Verifier?
81.1.1. Testing issues
81.2. Purposes
81.3. How It Works
81.3.1. Defining the contract
81.3.2. Client Side
81.3.3. Server Side
81.4. Step-by-step Guide to Consumer Driven Contracts (CDC)
81.4.1. Technical note
81.4.2. Consumer side (Loan Issuance)
81.4.3. Producer side (Fraud Detection server)
81.4.4. Consumer Side (Loan Issuance) Final Step
81.5. Dependencies
81.6. Additional Links
81.6.1. Spring Cloud Contract video
81.6.2. Readings
81.7. Samples
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 Camel
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 Integration
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 Stream
85.4.1. Adding the Runner to the Project
85.4.2. Disabling the functionality
Scenario 1 (no input message)
Scenario 2 (output triggered by input)
Scenario 3 (input with no output)
85.5. Stub Runner Spring AMQP
85.5.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
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. TLS certificate authentication
94.6. Cubbyhole authentication
95. Secret Backends
95.1. Generic Backend
95.2. Consul
95.3. RabbitMQ
95.4. AWS
96. Database backends
96.1. Apache Cassandra
96.2. MongoDB
96.3. MySQL
96.4. 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