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

Unable to explicitly set no key in kafka franz output #2423

Closed
davidshrive opened this issue Mar 14, 2024 · 3 comments
Closed

Unable to explicitly set no key in kafka franz output #2423

davidshrive opened this issue Mar 14, 2024 · 3 comments
Labels
needs investigation It looks as though have all the information needed but investigation is required outputs Any tasks or issues relating specifically to outputs

Comments

@davidshrive
Copy link

Previously when using the kafka output we used the following interpolation to set the kafka key.

      key: ${!meta("kafka_key").not_null().catch("")}

The behaviour here was to use the kafka_key added at input if its available but if not, don't error and don't set a key.

However when using the exact same config on the kafka_franz output the behaviour changed as the 0 length string was instead used as the key, causing everything to go to the same partition. I also tried catch(null) which did the same thing.

@Jeffail
Copy link
Collaborator

Jeffail commented Mar 14, 2024

@davidshrive you could do ${!meta("kafka_key").not_null().catch(uuid_v4())}

@davidshrive
Copy link
Author

Yes, our solution for the moment is to always set a key. I do think it would be good to have the option to set no key though.

@Jeffail
Copy link
Collaborator

Jeffail commented Mar 15, 2024

I actually think having an empty key route to the same partition might be less confusing than what the original kafka output is doing, as the latter must be generating a random hash when the key is empty which is a hidden magic behaviour.

If you don't want to partition based on the key itself there's also the option of alternative partitioning schemes: https://www.benthos.dev/docs/components/outputs/kafka_franz#partitioner.

@Jeffail Jeffail added outputs Any tasks or issues relating specifically to outputs needs investigation It looks as though have all the information needed but investigation is required labels Mar 15, 2024
@Jeffail Jeffail closed this as completed Mar 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs investigation It looks as though have all the information needed but investigation is required outputs Any tasks or issues relating specifically to outputs
Projects
None yet
Development

No branches or pull requests

2 participants