Spring Cloud Stream Germantown.M1 /2.2.0.M1 发布公告

工程 | Oleg Zhurakousky | 2019 年 3 月 26 日 | ...

我们很高兴地宣布 Spring Cloud Stream Germantown 发布系列的第一个里程碑版本 - Germantown.M1/2.2.0.M1。

Spring Cloud Stream Germantown 2.2.0.M1 可在 Spring Milestone 仓库中使用。

一些亮点

改进的主页和用户文档

请查看我们的新主页用户指南

进一步的功能编程增强

我们添加了额外的功能编程增强和简化,不再需要提供 @EnableBinding 注解,并且在某些情况下可能不需要 `spring.cloud.stream.definition` 属性。 考虑以下情况

@SpringBootApplication
public class SimpleFunctionRabbitDemoApplication {

    public static void main(String[] args) throws Exception {
        SpringApplication.run(SimpleFunctionRabbitDemoApplication.class);
    }

    @Bean
    public Function<String, String> echo() {
        return v -> v;
    }
}

在没有任何附加属性和/或注解的情况下,以上是一个完全正常运行的 Spring Cloud Stream 应用程序,基于框架能够从上述代码中确定的内容,绑定为 Processor。 随后,以下内容将绑定为 Sink

@SpringBootApplication
public class SimpleFunctionRabbitDemoApplication {

    public static void main(String[] args) throws Exception {
        SpringApplication.run(SimpleFunctionRabbitDemoApplication.class);
    }

    @Bean
    public Consumer<String> log() {
        return System.out::println;
    }
}

请注意,不再有 @EnableBinding 注解,也没有 `spring.cloud.stream.function.definition` 属性,因为框架能够根据应用程序上下文中只有一个可用的函数 bean 来确定意图。 如果有多个,或者您想要从多个函数中组合函数,您仍然可以提供 `spring.cloud.stream.function.definition` 属性

函数式 Kafka Streams

秉承我们在 Germantown 中推动的主题,Kafka Streams binder 现在也支持使用函数式编程模型编写应用程序。 您可以简单地定义类型为 `java.util.Function|Consumer` 的 bean,而不是使用 `StreamListener` 和 `SendTo` 来组合您的处理器,binder 会委托给适当的绑定。 此功能仍在 Kafka Streams binder 中发展,请关注此空间,了解更多改进、细节和示例应用程序,因为我们将通过 Germantown 的进一步里程碑取得进展。

每个绑定的重试模板

能够为 每个绑定 配置 RetryTemplate。

许多增强功能和错误修复

注意

如果应用程序是从 Spring Initializr 创建的,则它们需要在 spring-cloud BOM 声明之前在 maven 依赖管理中添加此 BOM 代码段,否则您将获得最新的快照

<dependency>
           <groupId>org.springframework.cloud</groupId>
           <artifactId>spring-cloud-stream-dependencies</artifactId>
           <version>Germantown.M1</version>
           <type>pom</type>
           <scope>import</scope>
</dependency>

此外,请密切关注我们最新的 AWS Kinesis binder,它刚刚发布了 v1.1.0。

后续步骤

与往常一样,我们欢迎反馈和贡献,所以请通过 StackoverflowGitHub 或通过 Gitter 联系我们。

获取 Spring 新闻简报

通过 Spring 新闻简报保持联系

订阅

领先一步

VMware 提供培训和认证,以加速您的进步。

了解更多

获得支持

Tanzu Spring 在一个简单的订阅中提供对 OpenJDK™、Spring 和 Apache Tomcat® 的支持和二进制文件。

了解更多

即将举行的活动

查看 Spring 社区中所有即将举行的活动。

查看全部