Spring Cloud Stream routing function custom header not present in consumer

303 Views Asked by At

I'm following this guide for event routing: https://docs.spring.io/spring-cloud-stream/docs/3.2.5-SNAPSHOT/reference/html/spring-cloud-stream.html#_event_routing

This is the configuration for the kinesis producer

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

This is the configuration for the kinesis consumers:

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

I am producig the message and setting the 'type' header with StreamBridge:

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

However, the 'type' header is not present in the consumer, hence the routing is not working for me.

What am I doing wrong?

1

There are 1 best solutions below

0
On

We have to add this to the producer configuration:

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