Is it necessary to serialize string values before producing messages in Kafka?

Viewed 346

I am using the Confluent Kafka Python client and I am writing a Producer.

The value of the messages that it will produce is a string. The method Producer.produce() accepts both str and bytes as value.

So, are there any benefits to serializing the string through StringSerializer before producing the message or can I just directly use the string?

1 Answers

The serializer would return bytes, but you might be able to control the encoding type. If you gave a string directly, it would assume UTF8 encoding

Related