0

I am using Spring cloud stream kafka for consuming and sending the message to another topic. I have setup compression-type as gzip and have partition Id as well like below which worked fine.

spring:
    cloud:
      stream:
        bindings:
          test-out-0:
             destination: test
             producer:
                partition-key-expression: headers['partitionKey']  
        kafka:
          bindings:
            test-out-0:
              producer:
                compression-type: gzip

I have a requirement where I have to send message to multiple topics which are dynamic in nature as I'll get the topic names in header. I am using StreamBridge to send message to outbound topics and as I said I am getting topic name from header. This worked fine but I want to pass partition Key as well. I couldnt find any config to pass partitionId for dynamic binder. Can somebody please help me to find what is the correct way to pass partition key.

Thanks

Sach
  • 41
  • 4
  • I could able to achieve this by passing kafka_messageKey into message header. Does it a right way to send same message into same partition? I tested with passing "kafka_messageKey" in message header and "partition-key-expression: headers['partitionKey']" with same message but both these options use different partition ID. So what is a right way to send same message into same Kafka topic partition? – Sach Jan 25 '23 at 10:03

0 Answers0