spring-cloud-stream icon indicating copy to clipboard operation
spring-cloud-stream copied to clipboard

Streambridge get wrong producer properties when sending partition message and non partition message

Open parkhaianh opened this issue 3 years ago • 0 comments

Hello, I am using Spring cloud stream kafka binder in my project( ver 3.1.4) I use StreamBridge for sending messages to multiple binding names. Some got partition key expression, others not. Problem occurs when i send 1st message to topic that got partition key expression, then sending to the other. But StreamBridge still keep the producer properties. Debuging i found Message<byte[]> resultMessage = (Message)((Function)functionToInvoke).apply(data); then jump to :

this.outputMessageEnricher = (output) -> {
               if (!(output instanceof Message)) {
                   output = MessageBuilder.withPayload(output).build();
               }

               int partitionId = partitionHandler.determinePartition((Message)output);
               return MessageBuilder.fromMessage((Message)output).setHeader("scst_partition", partitionId).build();
           };

This completely wrong because this object still keep partition key expression binding properties. It should return null for outputMessageEnricher Am I missing anything? Thank for helping me

parkhaianh avatar Aug 12 '22 16:08 parkhaianh