From 1aaadd9c58e2040b5fb64c1b22c7ea0b34a41c30 Mon Sep 17 00:00:00 2001 From: buildmaster Date: Tue, 28 Nov 2017 16:32:58 +0000 Subject: [PATCH] Sync docs from master to gh-pages --- ...addressing_all_instances_of_a_service.html | 2 +- multi/multi__addressing_an_instance.html | 2 +- ...multi__customizing_the_message_broker.html | 4 ++-- multi/multi__service_id_must_be_unique.html | 3 +++ multi/multi_spring-cloud-bus.html | 2 +- single/spring-cloud-bus.html | 4 ++-- spring-cloud-bus.html | 2 +- spring-cloud-bus.xml | 22 ++++++++++++++----- 8 files changed, 28 insertions(+), 13 deletions(-) create mode 100644 multi/multi__service_id_must_be_unique.html diff --git a/multi/multi__addressing_all_instances_of_a_service.html b/multi/multi__addressing_all_instances_of_a_service.html index 5568951..d5d8d26 100644 --- a/multi/multi__addressing_all_instances_of_a_service.html +++ b/multi/multi__addressing_all_instances_of_a_service.html @@ -1,3 +1,3 @@ - 3. Addressing all instances of a service

3. Addressing all instances of a service

The "destination" parameter is used in a Spring PathMatcher (with the path separator as a colon :) to determine if an instance will process the message. Using the example from above, "/bus/refresh?destination=customers:**" will target all instances of the "customers" service regardless of the profiles and ports set as the ApplicationContext ID.

\ No newline at end of file + 3. Addressing all instances of a service

3. Addressing all instances of a service

The "destination" parameter is used in a Spring PathMatcher (with the path separator as a colon :) to determine if an instance will process the message. Using the example from above, "/bus/refresh?destination=customers:**" will target all instances of the "customers" service regardless of the rest of the service ID.

\ No newline at end of file diff --git a/multi/multi__addressing_an_instance.html b/multi/multi__addressing_an_instance.html index 97ba0d5..73fd0a0 100644 --- a/multi/multi__addressing_an_instance.html +++ b/multi/multi__addressing_an_instance.html @@ -1,3 +1,3 @@ - 2. Addressing an Instance

2. Addressing an Instance

The HTTP endpoints accept a "destination" parameter, e.g. "/bus/refresh?destination=customers:9000", where the destination is an ApplicationContext ID. If the ID is owned by an instance on the Bus then it will process the message and all other instances will ignore it. Spring Boot sets the ID for you in the ContextIdApplicationContextInitializer to a combination of the spring.application.name, active profiles and server.port by default.

\ No newline at end of file + 2. Addressing an Instance

2. Addressing an Instance

Each instance of the application has a service ID, whose value can be set using spring.cloud.bus.id, and whose value is expected to be a colon-separated list of identifiers, in order of least specific to most specific. The default value is constructed from the environment as a combination of the spring.application.name and server.port (or spring.application.index if set). The default value of the ID is constructed in the form app:index:id where:

  • app is the vcap.application.name if it exists, or spring.application.name
  • index is the vcap.application.instance_index if it exists, or else spring.application.index, or else local.server.port (or server.port or 0).
  • id is the vcap.application.instance_id if it exists, or else a random value.

The HTTP endpoints accept a "destination" parameter, e.g. "/bus/refresh?destination=customers:9000", where the destination is a service ID. If the ID is owned by an instance on the Bus then it will process the message and all other instances will ignore it.

\ No newline at end of file diff --git a/multi/multi__customizing_the_message_broker.html b/multi/multi__customizing_the_message_broker.html index 9d3195b..5bb25ba 100644 --- a/multi/multi__customizing_the_message_broker.html +++ b/multi/multi__customizing_the_message_broker.html @@ -1,6 +1,6 @@ - 5. Customizing the Message Broker

5. Customizing the Message Broker

Spring Cloud Bus uses + 5. Customizing the Message Broker

5. Customizing the Message Broker

Spring Cloud Bus uses Spring Cloud Stream to broadcast the messages so to get messages to flow you only need to include the binder implementation of your choice in the @@ -14,4 +14,4 @@ configuration properties. Spring Cloud Bus has a handful of native configuration properties in spring.cloud.bus.* (e.g. spring.cloud.bus.destination is the name of the topic to use the the externall middleware). Normally the defaults will suffice.

To lean more about how to customize the message broker settings -consult the Spring Cloud Stream documentation.

\ No newline at end of file +consult the Spring Cloud Stream documentation.

\ No newline at end of file diff --git a/multi/multi__service_id_must_be_unique.html b/multi/multi__service_id_must_be_unique.html new file mode 100644 index 0000000..167ae27 --- /dev/null +++ b/multi/multi__service_id_must_be_unique.html @@ -0,0 +1,3 @@ + + + 4. Service ID must be unique

4. Service ID must be unique

The bus tries to eliminate processing an event twice, once from the original ApplicationEvent and once from the queue. To do this, it checks the sending service ID againts the current service ID. If multiple instances of a service have the same ID, events will not be processed. Running on a local machine, each service will be on a different port and that will be part of the ID. Cloud Foundry supplies an index to differentiate. To ensure that the ID is unique outside Cloud Foundry, set spring.application.index to something unique for each instance of a service.

\ No newline at end of file diff --git a/multi/multi_spring-cloud-bus.html b/multi/multi_spring-cloud-bus.html index 4d038a0..2af7334 100644 --- a/multi/multi_spring-cloud-bus.html +++ b/multi/multi_spring-cloud-bus.html @@ -1,3 +1,3 @@ - Spring Cloud Bus

Spring Cloud Bus


\ No newline at end of file + Spring Cloud Bus

Spring Cloud Bus


\ No newline at end of file diff --git a/single/spring-cloud-bus.html b/single/spring-cloud-bus.html index 2c04ea3..a5b1507 100644 --- a/single/spring-cloud-bus.html +++ b/single/spring-cloud-bus.html @@ -1,13 +1,13 @@ - Spring Cloud Bus

Spring Cloud Bus


Spring Cloud Bus links nodes of a distributed system with a lightweight message broker. This can then be used to broadcast state changes (e.g. configuration changes) or other management instructions. A key idea is that the Bus is like a distributed Actuator for a Spring Boot application that is scaled out, but it can also be used as a communication channel between apps. Starters are provided for an AMQP broker as the transport or for Kafka, but the same basic feature set (and some more depending on the transport) is on the roadmap for other transports.

[Note]Note

Spring Cloud is released under the non-restrictive Apache 2.0 license. If you would like to contribute to this section of the documentation or if you find an error, please find the source code and issue trackers in the project at github.

1. Quick Start

Spring Cloud Bus works by adding Spring Boot autconfiguration if it detects itself on the classpath. All you need to do to enable the bus is to add spring-cloud-starter-bus-amqp or spring-cloud-starter-bus-kafka to your dependency management and Spring Cloud takes care of the rest. Make sure the broker (RabbitMQ or Kafka) is available and configured: running on localhost you shouldn’t have to do anything, but if you are running remotely use Spring Cloud Connectors, or Spring Boot conventions to define the broker credentials, e.g. for Rabbit

application.yml.  + Spring Cloud Bus

Spring Cloud Bus


Spring Cloud Bus links nodes of a distributed system with a lightweight message broker. This can then be used to broadcast state changes (e.g. configuration changes) or other management instructions. A key idea is that the Bus is like a distributed Actuator for a Spring Boot application that is scaled out, but it can also be used as a communication channel between apps. Starters are provided for an AMQP broker as the transport or for Kafka, but the same basic feature set (and some more depending on the transport) is on the roadmap for other transports.

[Note]Note

Spring Cloud is released under the non-restrictive Apache 2.0 license. If you would like to contribute to this section of the documentation or if you find an error, please find the source code and issue trackers in the project at github.

1. Quick Start

Spring Cloud Bus works by adding Spring Boot autconfiguration if it detects itself on the classpath. All you need to do to enable the bus is to add spring-cloud-starter-bus-amqp or spring-cloud-starter-bus-kafka to your dependency management and Spring Cloud takes care of the rest. Make sure the broker (RabbitMQ or Kafka) is available and configured: running on localhost you shouldn’t have to do anything, but if you are running remotely use Spring Cloud Connectors, or Spring Boot conventions to define the broker credentials, e.g. for Rabbit

application.yml. 

spring:
   rabbitmq:
     host: mybroker.com
     port: 5672
     username: user
     password: secret

-

The bus currently supports sending messages to all nodes listening or all nodes for a particular service (as defined by Eureka). More selector criteria may be added in the future (ie. only service X nodes in data center Y, etc…​). There are also some http endpoints under the /bus/* actuator namespace. There are currently two implemented. The first, /bus/env, sends key/value pairs to update each node’s Spring Environment. The second, /bus/refresh, will reload each application’s configuration, just as if they had all been pinged on their /refresh endpoint.

[Note]Note

The Bus starters cover Rabbit and Kafka, because those are the two most common implementations, but Spring Cloud Stream is quite flexible and binder will work combined with spring-cloud-bus.

2. Addressing an Instance

The HTTP endpoints accept a "destination" parameter, e.g. "/bus/refresh?destination=customers:9000", where the destination is an ApplicationContext ID. If the ID is owned by an instance on the Bus then it will process the message and all other instances will ignore it. Spring Boot sets the ID for you in the ContextIdApplicationContextInitializer to a combination of the spring.application.name, active profiles and server.port by default.

3. Addressing all instances of a service

The "destination" parameter is used in a Spring PathMatcher (with the path separator as a colon :) to determine if an instance will process the message. Using the example from above, "/bus/refresh?destination=customers:**" will target all instances of the "customers" service regardless of the profiles and ports set as the ApplicationContext ID.

4. Application Context ID must be unique

The bus tries to eliminate processing an event twice, once from the original ApplicationEvent and once from the queue. To do this, it checks the sending application context id againts the current application context id. If multiple instances of a service have the same application context id, events will not be processed. Running on a local machine, each service will be on a different port and that will be part of the application context id. Cloud Foundry supplies an index to differentiate. To ensure that the application context id is the unique, set spring.application.index to something unique for each instance of a service. For example, in lattice, set spring.application.index=${INSTANCE_INDEX} in application.properties (or bootstrap.properties if using configserver).

5. Customizing the Message Broker

Spring Cloud Bus uses +

The bus currently supports sending messages to all nodes listening or all nodes for a particular service (as defined by Eureka). More selector criteria may be added in the future (ie. only service X nodes in data center Y, etc…​). There are also some http endpoints under the /bus/* actuator namespace. There are currently two implemented. The first, /bus/env, sends key/value pairs to update each node’s Spring Environment. The second, /bus/refresh, will reload each application’s configuration, just as if they had all been pinged on their /refresh endpoint.

[Note]Note

The Bus starters cover Rabbit and Kafka, because those are the two most common implementations, but Spring Cloud Stream is quite flexible and binder will work combined with spring-cloud-bus.

2. Addressing an Instance

Each instance of the application has a service ID, whose value can be set using spring.cloud.bus.id, and whose value is expected to be a colon-separated list of identifiers, in order of least specific to most specific. The default value is constructed from the environment as a combination of the spring.application.name and server.port (or spring.application.index if set). The default value of the ID is constructed in the form app:index:id where:

  • app is the vcap.application.name if it exists, or spring.application.name
  • index is the vcap.application.instance_index if it exists, or else spring.application.index, or else local.server.port (or server.port or 0).
  • id is the vcap.application.instance_id if it exists, or else a random value.

The HTTP endpoints accept a "destination" parameter, e.g. "/bus/refresh?destination=customers:9000", where the destination is a service ID. If the ID is owned by an instance on the Bus then it will process the message and all other instances will ignore it.

3. Addressing all instances of a service

The "destination" parameter is used in a Spring PathMatcher (with the path separator as a colon :) to determine if an instance will process the message. Using the example from above, "/bus/refresh?destination=customers:**" will target all instances of the "customers" service regardless of the rest of the service ID.

4. Service ID must be unique

The bus tries to eliminate processing an event twice, once from the original ApplicationEvent and once from the queue. To do this, it checks the sending service ID againts the current service ID. If multiple instances of a service have the same ID, events will not be processed. Running on a local machine, each service will be on a different port and that will be part of the ID. Cloud Foundry supplies an index to differentiate. To ensure that the ID is unique outside Cloud Foundry, set spring.application.index to something unique for each instance of a service.

5. Customizing the Message Broker

Spring Cloud Bus uses Spring Cloud Stream to broadcast the messages so to get messages to flow you only need to include the binder implementation of your choice in the diff --git a/spring-cloud-bus.html b/spring-cloud-bus.html index 872fbfa..e9519cd 100644 --- a/spring-cloud-bus.html +++ b/spring-cloud-bus.html @@ -90,7 +90,7 @@ $(addBlockSwitches);

-

1.3.3.BUILD-SNAPSHOT

+

2.0.0.BUILD-SNAPSHOT

diff --git a/spring-cloud-bus.xml b/spring-cloud-bus.xml index 5b62524..987b7bc 100644 --- a/spring-cloud-bus.xml +++ b/spring-cloud-bus.xml @@ -34,15 +34,27 @@ Addressing an Instance -The HTTP endpoints accept a "destination" parameter, e.g. "/bus/refresh?destination=customers:9000", where the destination is an ApplicationContext ID. If the ID is owned by an instance on the Bus then it will process the message and all other instances will ignore it. Spring Boot sets the ID for you in the ContextIdApplicationContextInitializer to a combination of the spring.application.name, active profiles and server.port by default. +Each instance of the application has a service ID, whose value can be set using spring.cloud.bus.id, and whose value is expected to be a colon-separated list of identifiers, in order of least specific to most specific. The default value is constructed from the environment as a combination of the spring.application.name and server.port (or spring.application.index if set). The default value of the ID is constructed in the form app:index:id where: + + +app is the vcap.application.name if it exists, or spring.application.name + + +index is the vcap.application.instance_index if it exists, or else spring.application.index, or else local.server.port (or server.port or 0). + + +id is the vcap.application.instance_id if it exists, or else a random value. + + +The HTTP endpoints accept a "destination" parameter, e.g. "/bus/refresh?destination=customers:9000", where the destination is a service ID. If the ID is owned by an instance on the Bus then it will process the message and all other instances will ignore it. Addressing all instances of a service -The "destination" parameter is used in a Spring PathMatcher (with the path separator as a colon :) to determine if an instance will process the message. Using the example from above, "/bus/refresh?destination=customers:**" will target all instances of the "customers" service regardless of the profiles and ports set as the ApplicationContext ID. +The "destination" parameter is used in a Spring PathMatcher (with the path separator as a colon :) to determine if an instance will process the message. Using the example from above, "/bus/refresh?destination=customers:**" will target all instances of the "customers" service regardless of the rest of the service ID. - -Application Context ID must be unique -The bus tries to eliminate processing an event twice, once from the original ApplicationEvent and once from the queue. To do this, it checks the sending application context id againts the current application context id. If multiple instances of a service have the same application context id, events will not be processed. Running on a local machine, each service will be on a different port and that will be part of the application context id. Cloud Foundry supplies an index to differentiate. To ensure that the application context id is the unique, set spring.application.index to something unique for each instance of a service. For example, in lattice, set spring.application.index=${INSTANCE_INDEX} in application.properties (or bootstrap.properties if using configserver). + +Service ID must be unique +The bus tries to eliminate processing an event twice, once from the original ApplicationEvent and once from the queue. To do this, it checks the sending service ID againts the current service ID. If multiple instances of a service have the same ID, events will not be processed. Running on a local machine, each service will be on a different port and that will be part of the ID. Cloud Foundry supplies an index to differentiate. To ensure that the ID is unique outside Cloud Foundry, set spring.application.index to something unique for each instance of a service. Customizing the Message Broker