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 可用。如果有多个 Bean,或者如果您想组合函数,您仍然可以提供 spring.cloud.stream.function.definition 属性

函数式 Kafka Streams

秉承我们在日耳曼敦(Germantown)推动的主要主题精神,Kafka Streams 绑定器现在也支持使用函数式编程模型编写应用程序。您可以使用 java.util.Function|Consumer 类型的 Bean 来代替 StreamListenerSendTo 来组合您的处理器,绑定器将委派给适当的绑定。此功能仍在 Kafka Streams 绑定器中不断发展,请关注此空间,以便随着我们在日耳曼敦(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 绑定器,它刚刚发布了 v1.1.0。

下一步

一如既往,我们欢迎反馈和贡献,因此请通过 StackoverflowGitHubGitter 与我们联系。

获取 Spring 新闻通讯

通过 Spring 新闻通讯保持联系

订阅

领先一步

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

了解更多

获得支持

Tanzu Spring 提供 OpenJDK™、Spring 和 Apache Tomcat® 的支持和二进制文件,只需一份简单的订阅。

了解更多

即将举行的活动

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

查看所有