The default serialization format for Kafka is Avro. I mentioned how to use this in C# yesterday.
Today I got into trouble when trying to send a specific message.
I changed the example a little bit to explicitly point out the issue. You see in the code above that I set the value for ‘Browser’ to ‘null’.
When trying to send this message it failed with the following error:
Local: Value serialization error
Let’s have a look at the related avro schema:
The problem is that in the schema is specified that the Browser field should a value of type string. ‘Null’ is not a valid value for string. This explains why it fails.
To solve this I have two options;
1) Either change the code to send an empty string instead of null:
2) Either update the schema to allow null values for the browser field:
More about Avro: https://en.wikipedia.org/wiki/Apache_Avro