Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeyedProducer doesn't actually send the key with the message #201

Closed
mjwillson opened this issue Aug 22, 2014 · 5 comments
Closed

KeyedProducer doesn't actually send the key with the message #201

mjwillson opened this issue Aug 22, 2014 · 5 comments

Comments

@mjwillson
Copy link

This was kind of unexpected. It seems it's only using the key locally to decide the partition, but not actually serializing it with the message.

Is this intentional? If so it's probably worth documenting so people don't go crazy trying to track down bugs with the missing keys. It'd be nice to have an option at least to serialize the key when using a KeyedProducer.

@mumrah
Copy link
Collaborator

mumrah commented Aug 22, 2014

Are you setting the key in the message as well? The Message struct has the key https://github.com/mumrah/kafka-python/blob/master/kafka/common.py#L47 which gets serialized later. This is a bit confusing, maybe KeyedProducer should just use the key on the Message

@mjwillson
Copy link
Author

So the API I was using is: KeyedProducer(...).send(topic, key, msg)

This expects strings for key and msg. I tried building a Message object and passing that as the msg parameter but it didn't work. It's building the Message itself from the string msg, and it doesn't pass in the key when doing so.

@mumrah
Copy link
Collaborator

mumrah commented Aug 22, 2014

Yup, you're right. That's a bug.

@mumrah mumrah added the bug label Aug 22, 2014
@dpkp dpkp added the producer label Aug 22, 2014
BecomingDitto pushed a commit to BecomingDitto/kafka-python that referenced this issue Sep 25, 2014
@se7entyse7en
Copy link
Contributor

I was also expecting the key in the message. Regarding #259 I think it's incorrect to expose a send_keyed_messages method in the Producer base class as it is subclassed also by SimpleProducer.

@dpkp
Copy link
Owner

dpkp commented Apr 6, 2015

Fixed in #268 . Additional fixes in #329

@dpkp dpkp closed this as completed Apr 6, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants