-
Maybe I'm missing something, but I cannot see how to specify which partition to produce to for a kafka producer. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
Hi, welcome. There is an option to allow clients to specify a strategy https://kafka.apache.org/documentation/#consumerconfigs_partition.assignment.strategy Edit: I was wrong. Forget what I said. |
Beta Was this translation helpful? Give feedback.
-
While this may be true, it is also possible to specify a partition on the client when producing to Kafka: https://docs.rs/rdkafka/0.36.0/rdkafka/producer/struct.BaseRecord.html (also in In my experience with Erlang/Elixir, I’ve been doing this with a custom hashing strategy on the client. I hash the key based on the the number of partitions and this gives me the partition to produce the message to. Having said that, I wasn’t aware you could have the broker do this, so thank you for pointing that out. Even if the broker picks the partition, I believe you still need to set a key so that it can pick a consistent partition for you, otherwise it would be round robin (which I usually never want). Even with all this, I'm still left puzzled on how you can set the key ( I apologize if I'm completely missing something, but from what I have read (including the code), I cannot seem to understand how to accomplish this with the |
Beta Was this translation helpful? Give feedback.
#17