Spring Boot 2.2.4/Hoxton.SR1 中的处理器应用程序在 Spring Cloud Data Flow 2.4.1 中不起作用 [英] Processor App in Spring Boot 2.2.4/Hoxton.SR1 not working in Spring Cloud Data Flow 2.4.1

查看:43
本文介绍了Spring Boot 2.2.4/Hoxton.SR1 中的处理器应用程序在 Spring Cloud Data Flow 2.4.1 中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试开发一个适用于 SCDF 2.4.1 和 Skipper 2.3.1 的新应用

I am trying to develop a new application to work on SCDF 2.4.1 and Skipper 2.3.1

我从https://github.com/sabbyanandan/stream-programming-models

我在本地构建它们.下载了 SCDF kafka 的 docker compose,设置版本并挂载我的 repo 并启动我的 docker compose.

I built them locally. Downloaded the docker compose for SCDF kafka, set the Versions and mount my repo and start my docker compose.

当我部署功能"模块并创建一个简单的流时http |定制鞋面 |日志

When I deploy the "function" module and create a simple stream http | customUpper | log

我看到示例工作正常并且能够按预期看到日志输出.

I see the sample working fine and able to see log output as expected.

当我修改函数流应用程序时,使用 Spring Boot、2.2.4 和 Hoxton.SR1 作为云流依赖项.我在日志中没有看到任何输出.

When I modify the function stream app, to use Spring Boot, 2.2.4 and Hoxton.SR1 for cloud stream dependencies. I do not see any output in the log.

启动应用

public class FunctionStreamSampleApplication {

    public static void main(String[] args) {
        SpringApplication.run(FunctionStreamSampleApplication.class, args);
    }

    @Bean
    public Function<String, String> uppercase() {

        return data -> {
            System.out.println("Input "+data);
            return data.toUpperCase();
        };
    }
}

application.yml
spring:
  cloud:
    stream:
      function:
        definition: uppercase

pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.2.4.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <artifactId>function219</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>function219</name>
    <description>Demo project for Spring Boot</description>

    <properties>
        <java.version>1.8</java.version>
        <spring-cloud.version>Hoxton.SR1</spring-cloud.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-function-context</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-stream-binder-kafka</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

    </dependencies>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>${spring-cloud.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

我删除了测试类只是为了将其剥离到最低限度以避免其他依赖.相同的应用程序在部署时确实可以使用它最初构建的 2.1.4 版本的 spring boot.请告知是否需要进行更改才能使其在 SCDF 上运行

I have removed the test classes just to strip it to bare minimum to avoid other dependency. The same app does work when deployed as is using the 2.1.4 version of spring boot it was originally built on. Do let know if there are changes needed to be done to make it work on SCDF

当我使用 kafkatools 检查流创建的主题时,我只在 streamname.http 中看到消息,但处理器似乎没有读取消息,因为我的 sysout 没有被打印.

When i use kafkatools to check the topics created by the stream, I see messages only in the streamname.http, but processor doesnt seem to be reading messages as my sysout is not getting printed.

推荐答案

对于基于函数的流模块与 SCDF 一起使用,您需要将适当的绑定名称属性添加到 inputoutput 到您的应用程序属性,如下所述:https://cloud.spring.io/spring-cloud-static/spring-cloud-stream/3.0.3.RELEASE/reference/html/spring-云流.html#_functional_binding_names

For function based stream modules to work with SCDF, you need to add the appropriate binding name properties to input and output to your application properties as described here: https://cloud.spring.io/spring-cloud-static/spring-cloud-stream/3.0.3.RELEASE/reference/html/spring-cloud-stream.html#_functional_binding_names

本质上,这将功能绑定端点名称映射到 SCDF 端点名称,inputoutput.例如,如果你有一个函数‘foo’:

Essentially, this maps the functional binding endpoint names to the SCDF endpoint names, input and output. For example, if you have a Function `foo':

spring.cloud.stream.function.bindings.foo-in-0=inputspring.cloud.stream.function.bindings.foo-out-0=output

. 预打包流模块的未来版本将使用功能范式并自动提供这些属性.

.Future releases of the prepackaged stream modules will use the Functional paradigm and will provide these properties automatically.

这篇关于Spring Boot 2.2.4/Hoxton.SR1 中的处理器应用程序在 Spring Cloud Data Flow 2.4.1 中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆