Spring Cloud Stream introduces quite a number of new features, enhancements and changes. The following sections outline most notable ones.
Introduction of polled consumers, where the application can control message processing rates. Please refer to the appropriate section for more details. You can also read this blog for more details spring.io/blog/2018/02/27/spring-cloud-stream-2-0-polled-consumers
Metrics has been switched to use Micrometer. MeterRegistry
is also provided as a bean so custom application can autowire it to capture custom metrics.
Please refer to the appropriate section for more details
There are now new new Actuator binding controls to both visualize as well as control Bindings lifecycle. For more details please visit Section 6.6, “Binding visualization and control”
This helps to slim down the footprint of the deployed application in the event neither of the functionality is required. It also allows one to swicth between the reactive and conventional web paradigms by adding one of the following dependencies manually:
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency>
or
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-webflux</artifactId> </dependency>
Actuator dependency can be added as follows:
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency>
One of the core themes for 2.0 is improvements (both consistency and performance) around content-type negotiation and message conversion. The following summary outlines notable changes and improvements. Please refer to the appropriate section for more details as well as this blog spring.io/blog/2018/02/26/spring-cloud-stream-2-0-content-type-negotiation-and-transformation.
MessageConverters
.@StreamMessageConverter
annotation to provide custom MessageConverters
.application/json
which needs to be taken into consideration when migrating 1.3
application and/or operating in the mixed mode (i.e., 1.3 producer → 2.0 consumer).text/…
or …/json
are no longer converted to Message<String>
for cases where argument type of the provided MessageHandler
can not be determnied (i.e., public void handle(Message<?> message)
or public void handle(Object payload)
). Further more, a strong argument type may not be enough
to properly convert messages, so contentType
header is may be used as supplement by some MessageConverters
.JavaSerializationMessageConverter
and KryoMessageConverter
. While these two converters remain for now, they will be moved out of the core packages and support in the future.
The main reason for this deprecation is to signal the issue type-based language-specific serialization couuld cause in the distributed environments, where Producers and Consumers
may not only depend on different JVM versions or have different versions of supporting libraries (i.e., Kryo), but to also draw the attention to the fact that Consumers and Producers
may and in a lot of cases are non-Java based.Following is a quick summary of notable deprecations. See corresponding javadocs fort more details.
SharedChannelRegistry
in favor of SharedBindingTargetRegistry
.Bindings
- beans qualified by it are already uniquely identified by their type. For example, provided Source
, Processor
or custom bindings:public interface Foo { String OUTPUT = "fooOutput"; @Output(Foo.OUTPUT) MessageChannel output(); }
HeaderMode.raw
. Use none
, headers
or embeddedHeaders
ProducerProperties.partitionKeyExtractorClass
in favor of partitionKeyExtractorName
and ProducerProperties.partitionSelectorClass
in favor of partitionSelectorName
.
This is to ensure that both components are Spring configured/managed and referenced in Spring-friendly way.BinderAwareRouterBeanPostProcessor
- while the component exists it is no longer a Bean Post Processor and will be renamed in the future.BinderProperties.setEnvironment(Properties environment)
in favor of BinderProperties.setEnvironment(Map<String, Object> environment)
.This section goes into more detail about how you can work with Spring Cloud Stream. It covers topics such as creating and running stream applications.