32 lines
15 KiB
HTML
32 lines
15 KiB
HTML
<html><head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
|
<title>3. What’s New in 2.0?</title><link rel="stylesheet" type="text/css" href="css/manual-multipage.css"><meta name="generator" content="DocBook XSL Stylesheets V1.79.1"><link rel="home" href="multi_spring-cloud-stream.html" title="Spring Cloud Stream Reference Guide"><link rel="up" href="multi__preface.html" title="Part I. Preface"><link rel="prev" href="multi__quick_start.html" title="2. Quick Start"><link rel="next" href="multi_spring-cloud-stream-overview-introducing.html" title="4. Introducing Spring Cloud Stream"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">3. What’s New in 2.0?</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="multi__quick_start.html">Prev</a> </td><th width="60%" align="center">Part I. Preface</th><td width="20%" align="right"> <a accesskey="n" href="multi_spring-cloud-stream-overview-introducing.html">Next</a></td></tr></table><hr></div><div class="chapter"><div class="titlepage"><div><div><h2 class="title"><a name="_whats_new_in_2_0" href="#_whats_new_in_2_0"></a>3. What’s New in 2.0?</h2></div></div></div><p>Spring Cloud Stream introduces a number of new features, enhancements, and changes. The following sections outline the most notable ones:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><a class="xref" href="multi__whats_new_in_2_0.html#spring-cloud-stream-preface-new-features" title="3.1 New Features and Components">Section 3.1, “New Features and Components”</a></li><li class="listitem"><a class="xref" href="multi__whats_new_in_2_0.html#spring-cloud-stream-preface-notable-enhancements" title="3.2 Notable Enhancements">Section 3.2, “Notable Enhancements”</a></li></ul></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="spring-cloud-stream-preface-new-features" href="#spring-cloud-stream-preface-new-features"></a>3.1 New Features and Components</h2></div></div></div><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><span class="strong"><strong>Polling Consumers</strong></span>: Introduction of polled consumers, which lets the application control message processing rates.
|
|
See <span class="quote">“<span class="quote"><a class="xref" href="multi__programming_model.html#spring-cloud-streams-overview-using-polled-consumers" title="6.3.5 Using Polled Consumers">Section 6.3.5, “Using Polled Consumers”</a></span>”</span> for more details.
|
|
You can also read <a class="link" href="https://spring.io/blog/2018/02/27/spring-cloud-stream-2-0-polled-consumers" target="_top">this blog post</a> for more details.</li><li class="listitem"><span class="strong"><strong>Micrometer Support</strong></span>: Metrics has been switched to use <a class="link" href="https://micrometer.io/" target="_top">Micrometer</a>.
|
|
<code class="literal">MeterRegistry</code> is also provided as a bean so that custom applications can autowire it to capture custom metrics.
|
|
See <span class="quote">“<span class="quote"><a class="xref" href="multi_spring-cloud-stream-overview-metrics-emitter.html" title="14. Metrics Emitter">Chapter 14, <i>Metrics Emitter</i></a></span>”</span> for more details.</li><li class="listitem"><span class="strong"><strong>New Actuator Binding Controls</strong></span>: New actuator binding controls let you both visualize and control the Bindings lifecycle.
|
|
For more details, see <a class="xref" href="multi_spring-cloud-stream-overview-binders.html#_binding_visualization_and_control" title="7.6 Binding visualization and control">Section 7.6, “Binding visualization and control”</a>.</li><li class="listitem"><span class="strong"><strong>Configurable RetryTemplate</strong></span>: Aside from providing properties to configure <code class="literal">RetryTemplate</code>, we now let you provide your own template, effectively overriding the one provided by the framework.
|
|
To use it, configure it as a <code class="literal">@Bean</code> in your application.</li></ul></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="spring-cloud-stream-preface-notable-enhancements" href="#spring-cloud-stream-preface-notable-enhancements"></a>3.2 Notable Enhancements</h2></div></div></div><p>This version includes the following notable enhancements:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><a class="xref" href="multi__whats_new_in_2_0.html#spring-cloud-stream-preface-actuator-web-dependencies" title="3.2.1 Both Actuator and Web Dependencies Are Now Optional">Section 3.2.1, “Both Actuator and Web Dependencies Are Now Optional”</a></li><li class="listitem"><a class="xref" href="multi__whats_new_in_2_0.html#spring-cloud-stream-preface-content-type-negotiation-improvements" title="3.2.2 Content-type Negotiation Improvements">Section 3.2.2, “Content-type Negotiation Improvements”</a></li><li class="listitem"><a class="xref" href="multi__whats_new_in_2_0.html#spring-cloud-stream-preface-notable-deprecations" title="3.3 Notable Deprecations">Section 3.3, “Notable Deprecations”</a></li></ul></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="spring-cloud-stream-preface-actuator-web-dependencies" href="#spring-cloud-stream-preface-actuator-web-dependencies"></a>3.2.1 Both Actuator and Web Dependencies Are Now Optional</h3></div></div></div><p>This change slims down the footprint of the deployed application in the event neither actuator nor web dependencies required.
|
|
It also lets you switch between the reactive and conventional web paradigms by manually adding one of the following dependencies.</p><p>The following listing shows how to add the conventional web framework:</p><pre class="programlisting"><span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"><dependency></span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"><groupId></span>org.springframework.boot<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"></groupId></span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"><artifactId></span>spring-boot-starter-web<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"></artifactId></span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"></dependency></span></pre><p>The following listing shows how to add the reactive web framework:</p><pre class="programlisting"><span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"><dependency></span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"><groupId></span>org.springframework.boot<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"></groupId></span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"><artifactId></span>spring-boot-starter-webflux<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"></artifactId></span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"></dependency></span></pre><p>The following list shows how to add the actuator dependency:</p><pre class="programlisting"><span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"><dependency></span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"><groupId></span>org.springframework.boot<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"></groupId></span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"><artifactId></span>spring-boot-starter-actuator<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"></artifactId></span>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"></dependency></span></pre></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="spring-cloud-stream-preface-content-type-negotiation-improvements" href="#spring-cloud-stream-preface-content-type-negotiation-improvements"></a>3.2.2 Content-type Negotiation Improvements</h3></div></div></div><p>One of the core themes for verion 2.0 is improvements (in both consistency and performance) around content-type negotiation and message conversion.
|
|
The following summary outlines the notable changes and improvements in this area.
|
|
See the <span class="quote">“<span class="quote"><a class="xref" href="multi_content-type-management.html" title="9. Content Type Negotiation">Chapter 9, <i>Content Type Negotiation</i></a></span>”</span> section for more details.
|
|
Also <a class="link" href="https://spring.io/blog/2018/02/26/spring-cloud-stream-2-0-content-type-negotiation-and-transformation" target="_top">this blog post</a> contains more detail.</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">All message conversion is now handled <span class="strong"><strong>only</strong></span> by <code class="literal">MessageConverter</code> objects.</li><li class="listitem">We introduced the <code class="literal">@StreamMessageConverter</code> annotation to provide custom <code class="literal">MessageConverter</code> objects.</li><li class="listitem">We introduced the default <code class="literal">Content Type</code> as <code class="literal">application/json</code>, which needs to be taken into consideration when migrating 1.3 application or operating in the mixed mode (that is, 1.3 producer → 2.0 consumer).</li><li class="listitem">Messages with textual payloads and a <code class="literal">contentType</code> of <code class="literal">text/…​</code> or <code class="literal">…​/json</code> are no longer converted to <code class="literal">Message<String></code> for cases where the argument type of the provided <code class="literal">MessageHandler</code> can not be determined (that is, <code class="literal">public void handle(Message<?> message)</code> or <code class="literal">public void handle(Object payload)</code>).
|
|
Furthermore, a strong argument type may not be enough to properly convert messages, so the <code class="literal">contentType</code> header may be used as a supplement by some <code class="literal">MessageConverters</code>.</li></ul></div></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="spring-cloud-stream-preface-notable-deprecations" href="#spring-cloud-stream-preface-notable-deprecations"></a>3.3 Notable Deprecations</h2></div></div></div><p>As of version 2.0, the following items have been deprecated:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><a class="xref" href="multi__whats_new_in_2_0.html#spring-cloud-stream-preface-deprecation-java-serialization" title="3.3.1 Java Serialization (Java Native and Kryo)">Section 3.3.1, “Java Serialization (Java Native and Kryo)”</a></li><li class="listitem"><a class="xref" href="multi__whats_new_in_2_0.html#spring-cloud-stream-preface-deprecation-classes-methods" title="3.3.2 Deprecated Classes and Methods">Section 3.3.2, “Deprecated Classes and Methods”</a></li></ul></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="spring-cloud-stream-preface-deprecation-java-serialization" href="#spring-cloud-stream-preface-deprecation-java-serialization"></a>3.3.1 Java Serialization (Java Native and Kryo)</h3></div></div></div><p><code class="literal">JavaSerializationMessageConverter</code> and <code class="literal">KryoMessageConverter</code> remain for now. However, we plan to move them out of the core packages and support in the future.
|
|
The main reason for this deprecation is to flag the issue that type-based, language-specific serialization could cause in distributed environments, where Producers and Consumers may depend on different JVM versions or have different versions of supporting libraries (that is, Kryo).
|
|
We also wanted to draw the attention to the fact that Consumers and Producers may not even be Java-based, so polyglot style serialization (i.e., JSON) is better suited.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="spring-cloud-stream-preface-deprecation-classes-methods" href="#spring-cloud-stream-preface-deprecation-classes-methods"></a>3.3.2 Deprecated Classes and Methods</h3></div></div></div><p>The following is a quick summary of notable deprecations. See the corresponding {spring-cloud-stream-javadoc-current}[javadoc] for more details.</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><code class="literal">SharedChannelRegistry</code>. Use <code class="literal">SharedBindingTargetRegistry</code>.</li><li class="listitem"><code class="literal">Bindings</code>.
|
|
Beans qualified by it are already uniquely identified by their type — for example, provided <code class="literal">Source</code>, <code class="literal">Processor</code>, or custom bindings:</li></ul></div><pre class="screen">public interface Sample {
|
|
String OUTPUT = "sampleOutput";
|
|
|
|
@Output(Sample.OUTPUT)
|
|
MessageChannel output();
|
|
}</pre><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><code class="literal">HeaderMode.raw</code>. Use <code class="literal">none</code>, <code class="literal">headers</code> or <code class="literal">embeddedHeaders</code></li><li class="listitem"><code class="literal">ProducerProperties.partitionKeyExtractorClass</code> in favor of <code class="literal">partitionKeyExtractorName</code> and <code class="literal">ProducerProperties.partitionSelectorClass</code> in favor of <code class="literal">partitionSelectorName</code>.
|
|
This change ensures that both components are Spring configured and managed and are referenced in a Spring-friendly way.</li><li class="listitem"><code class="literal">BinderAwareRouterBeanPostProcessor</code>. While the component remains, it is no longer a <code class="literal">BeanPostProcessor</code> and will be renamed in the future.</li><li class="listitem"><code class="literal">BinderProperties.setEnvironment(Properties environment)</code>. Use <code class="literal">BinderProperties.setEnvironment(Map<String, Object> environment)</code>.</li></ul></div></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="multi__quick_start.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="multi__preface.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="multi_spring-cloud-stream-overview-introducing.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">2. Quick Start </td><td width="20%" align="center"><a accesskey="h" href="multi_spring-cloud-stream.html">Home</a></td><td width="40%" align="right" valign="top"> 4. Introducing Spring Cloud Stream</td></tr></table></div></body></html> |