Binary producer/consumer for kafka #1440
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Why we need this change - in current implementation Wolverine is serializing message using IMessageSerializer to bytes but in kafka ProducerBuilder<string, string> is used to we are transforming this to string with Encoding.Default.GetString and inside IProducer<string, string>.ProduceAsync() another method is used to change this to bytes again with Encoding.Default.GetBytes (https://github.com/confluentinc/confluent-kafka-dotnet/blob/3f10fc8f829e7540e135fe8fe343371f1d4f5f2b/src/Confluent.Kafka/Serializers.cs#L42). So there is additional overhead that could be simplified by using ProducerBuilder<string, byte[]>.
Additionally in our case we implemented custom serializer using confluent avro and during tests we saw that Encoding.Default is not enough and byte array we get when deserializing are different. After investigation we find out that bytes produced by avro can't be change to UTF8 - it works only when we changed woverine code to Encoding.Unicode.