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
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. 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. BackOff Policies
22.6.2. Configuration
22.6.3. 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 FAQ
82.1. Why use Spring Cloud Contract Verifier and not X ?
82.2. What is this value(consumer(), producer()) ?
82.3. How to do Stubs versioning?
82.3.1. API Versioning
82.3.2. JAR versioning
82.3.3. Dev or prod stubs
82.4. Common repo with contracts
82.4.1. Repo structure
82.4.2. Workflow
82.4.3. Consumer
82.4.4. Producer
82.5. Can I have multiple base classes for tests?
82.6. How can I debug the request/response being sent by the generated tests client?
82.6.1. How can I debug the mapping/request/response being sent by WireMock?
82.6.2. How can I see what got registered in the HTTP server stub?
82.6.3. Can I reference the request from the response?
82.6.4. Can I reference text from file?
83. Spring Cloud Contract Verifier Setup
83.1. Gradle Project
83.1.1. Prerequisites
83.1.2. Add Gradle Plugin with Dependencies
83.1.3. Gradle and Rest Assured 2.0
83.1.4. Snapshot Versions for Gradle
83.1.5. Add stubs
83.1.6. Run the Plugin
83.1.7. Default Setup
83.1.8. Configure Plugin
83.1.9. Configuration Options
83.1.10. Single Base Class for All Tests
83.1.11. Different Base Classes for Contracts
83.1.12. Invoking Generated Tests
83.1.13. Spring Cloud Contract Verifier on the Consumer Side
83.2. Maven Project
83.2.1. Add maven plugin
83.2.2. Maven and Rest Assured 2.0
83.2.3. Snapshot versions for Maven
83.2.4. Add stubs
83.2.5. Run plugin
83.2.6. Configure plugin
83.2.7. Configuration Options
83.2.8. Single Base Class for All Tests
83.2.9. Different base classes for contracts
83.2.10. Invoking generated tests
83.2.11. Maven Plugin and STS
83.2.12. Spring Cloud Contract Verifier on the Consumer Side
83.3. Stubs and Transitive Dependencies
83.4. Scenarios
84. Spring Cloud Contract Verifier Messaging
84.1. Integrations
84.2. Manual Integration Testing
84.3. Publisher-Side Test Generation
84.3.1. Scenario 1: No Input Message
84.3.2. Scenario 2: Output Triggered by Input
84.3.3. Scenario 3: No Output Message
84.4. Consumer Stub Generation
85. Spring Cloud Contract Stub Runner
85.1. Snapshot versions
85.2. Publishing Stubs as JARs
85.3. Stub Runner Core
85.3.1. Retrieving stubs
Stub downloading
Classpath scanning
85.3.2. Running stubs
Limitations
Running using main app
HTTP Stubs
Viewing registered mappings
Messaging Stubs
85.4. Stub Runner JUnit Rule
85.4.1. Maven settings
85.4.2. Providing fixed ports
85.4.3. Fluent API
85.4.4. Stub Runner with Spring
85.5. Stub Runner Spring Cloud
85.5.1. Stubbing Service Discovery
Test profiles and service discovery
85.5.2. Additional Configuration
85.6. Stub Runner Boot Application
85.6.1. How to use it?
Stub Runner Server
Spring Cloud CLI
85.6.2. Endpoints
HTTP
Messaging
85.6.3. Example
85.6.4. Stub Runner Boot with Service Discovery
85.7. Stubs Per Consumer
85.8. Common
85.8.1. Common Properties for JUnit and Spring
85.8.2. Stub Runner Stubs IDs
86. Stub Runner for Messaging
86.1. Stub triggering
86.1.1. Trigger by Label
86.1.2. Trigger by Group and Artifact Ids
86.1.3. Trigger by Artifact Ids
86.1.4. Trigger All Messages
86.2. Stub Runner Camel
86.2.1. Adding the Runner to the Project
86.2.2. Disabling the functionality
Scenario 1 (no input message)
Scenario 2 (output triggered by input)
Scenario 3 (input with no output)
86.3. Stub Runner Integration
86.3.1. Adding the Runner to the Project
86.3.2. Disabling the functionality
Scenario 1 (no input message)
Scenario 2 (output triggered by input)
Scenario 3 (input with no output)
86.4. Stub Runner Stream
86.4.1. Adding the Runner to the Project
86.4.2. Disabling the functionality
Scenario 1 (no input message)
Scenario 2 (output triggered by input)
Scenario 3 (input with no output)
86.5. Stub Runner Spring AMQP
86.5.1. Adding the Runner to the Project
Triggering the message
Spring AMQP Test Configuration
87. Contract DSL
87.1. Limitations
87.2. Common Top-Level elements
87.2.1. Description
87.2.2. Name
87.2.3. Ignoring Contracts
87.2.4. Passing Values from Files
87.2.5. HTTP Top-Level Elements
87.3. Request
87.4. Response
87.5. Dynamic properties
87.5.1. Dynamic properties inside the body
87.5.2. Regular expressions
87.5.3. Passing Optional Parameters
87.5.4. Executing Custom Methods on the Server Side
87.5.5. Referencing the Request from the Response
87.5.6. Registering Your Own WireMock Extension
87.5.7. Dynamic Properties in the Matchers Sections
87.6. JAX-RS Support
87.7. Async Support
87.8. Working with Context Paths
87.9. Messaging Top-Level Elements
87.9.1. Output Triggered by a Method
87.9.2. Output Triggered by a Message
87.9.3. Consumer/Producer
87.9.4. Common
87.10. Multiple Contracts in One File
88. Customization
88.1. Extending the DSL
88.1.1. Common JAR
88.1.2. Adding the Dependency to the Project
88.1.3. Test the Dependency in the Project’s Dependencies
88.1.4. Test a Dependency in the Plugin’s Dependencies
88.1.5. Referencing classes in DSLs
89. Using the Pluggable Architecture
89.1. Custom Contract Converter
89.1.1. Pact Converter
89.1.2. Pact Contract
89.1.3. Pact for Producers
89.1.4. Pact for Consumers
89.2. Using the Custom Test Generator
89.3. Using the Custom Stub Generator
89.4. Using the Custom Stub Runner
89.5. Using the Custom Stub Downloader
90. Spring Cloud Contract WireMock
90.1. Registering Stubs Automatically
90.2. Using Files to Specify the Stub Bodies
90.3. Alternative: Using JUnit Rules
90.4. Relaxed SSL Validation for Rest Template
90.5. WireMock and Spring MVC Mocks
90.6. Generating Stubs using REST Docs
90.7. Generating Contracts by Using REST Docs
91. Migrations
91.1. 1.0.x → 1.1.x
91.1.1. New structure of generated stubs
91.2. 1.1.x → 1.2.x
91.2.1. Custom HttpServerStub
91.2.2. New packages for generated tests
91.2.3. New Methods in TemplateProcessor
91.2.4. RestAssured 3.0
92. Links
XIII. Spring Cloud Vault
93. Quick Start
94. Client Side Usage
94.1. Authentication
95. Authentication methods
95.1. Token authentication
95.2. AppId authentication
95.2.1. Custom UserId
95.3. AppRole authentication
95.4. AWS-EC2 authentication
95.5. AWS-IAM authentication
95.6. TLS certificate authentication
95.7. Cubbyhole authentication
95.8. Kubernetes authentication
96. Secret Backends
96.1. Generic Backend
96.2. Consul
96.3. RabbitMQ
96.4. AWS
97. Database backends
97.1. Apache Cassandra
97.2. MongoDB
97.3. MySQL
97.4. PostgreSQL
98. Configure PropertySourceLocator behavior
99. Service Registry Configuration
100. Vault Client Fail Fast
101. Vault Client SSL configuration
102. Lease lifecycle management (renewal and revocation)
XIV. Appendix: Compendium of Configuration Properties