多个Spring Cloud Stream应用程序一起运行

Anu*_*pta 2 spring-cloud-stream spring-kafka

我参考了此处发布的示例。我正在尝试一起运行多个 Spring Cloud Stream 应用程序。这里第一个的输出作为其他的输入。以下是我正在尝试做的事情。

@Bean
    public Function<KStream<FormUUID, FormData>, KStream<UUID, Application>> process()
    {
        //do some processing here and return 
    }
// read output from above process and join it with an event stream
@Bean
    public BiConsumer<KStream<UUID, ProcessEvent>, KTable<UUID, Application>> listen()
    {

        return (eventStream,appTable )-> eventStream
                .join(appTable, (event, app) -> app).foreach((k, app) -> app.createQuote());

    }
Run Code Online (Sandbox Code Playgroud)

application.yml 如下所示

spring.cloud:
 function: process;listen
 stream:
  kafka.streams:
    bindings:
      process-in-0.consumer.application-id: form-aggregator
      listen-in-0.consumer.application-id: event-processor
      listen-in-1.consumer.application-id: event-processor
    binder.configuration:
      default.key.serde: org.springframework.kafka.support.serializer.JsonSerde
      default.value.serde: org.springframework.kafka.support.serializer.JsonSerde
      spring.json.key.default.type: com.xxx.datamapper.domain.FormUUID
      spring.json.value.default.type: com.xxx.datamapper.domain.FormData
      commit.interval.ms: 1000
  bindings:
    process-in-0.destination: FORM_DATA_TOPIC
    process-out-0.destination: APPLICATION_TOPIC
    listen-in-0.destination: APPLICATION_TOPIC
    listen-in-1.destination: PROCESS_TOPIC
Run Code Online (Sandbox Code Playgroud)

以上配置抛出

java.lang.IllegalStateException: Multiple functions found, but function definition property is not set.
Run Code Online (Sandbox Code Playgroud)

如果我尝试使用下面的配置

spring.cloud.stream.function.definition: processAndListen
Run Code Online (Sandbox Code Playgroud)

然后我的应用程序可以工作,但第二个流配置(在监听 Bean 中定义)没有被执行。

sob*_*cko 5

在您的属性中,您需要添加以下内容:

spring.cloud:
 function.definition: process;listen
Run Code Online (Sandbox Code Playgroud)

这也应该有效 - spring.cloud.stream.function.definition: process;listen

什么是processAndListen。这个价值从何而来?