消费者中不存在Spring Cloud Stream Routing函数自定义标头

w8ntj3qf  于 2022-10-04  发布在  Spring
关注(0)|答案(1)|浏览(150)

我遵循以下活动路线指南:https://docs.spring.io/spring-cloud-stream/docs/3.2.5-SNAPSHOT/reference/html/spring-cloud-stream.html#_event_routing

这是Kinesis生成器的配置

cloud:
    stream:
      bindings:
        produceMessage-out-0:
          binder: kinesis
          destination: 'kinesis-stream-name'
          content-type: application/json

这是针对Kinesis消费者的配置:

spring:
  cloud:
    function:
      definition: even;odd
    stream:
      function:
        routing:
          enabled: true
      bindings:
        even-in-0:
          destination: 'kinesis-stream-name'
          content-type: application/json
        odd-in-0:
          destination: 'kinesis-stream-name'
          content-type: application/json

我正在生成消息并使用StreamBridge设置‘type’标头:

streamBridge.send("kinesis-stream-name", MessageBuilder.withPayload("10").setHeader("type","odd").build());

然而,‘type’标头不存在于消费者中,因此路由对我不起作用。

我做错了什么?

oxcyiej7

oxcyiej71#

我们必须将以下代码添加到生产者配置中:

spring:
 cloud:
  stream:
   kinesis:
    binder:
     headers:
      - type

相关问题