Skip to content

Commit e05177c

Browse files
authored
Update README.md
1 parent 3fe22a3 commit e05177c

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
Apache Kafka is an event streaming platform used to collect, store and process real time data streams at scale.
33
It has numerous use cases, including distributed logging, stream processing and Pub-Sub Messaging.
44

5+
6+
57
<img width="700" alt="image" src="https://github.com/akhanalcs/dotnet-kafka/assets/30603497/19978d3c-3f9c-4474-9a3b-995b5ea437ed">
68

79
## Helpful Links
@@ -466,6 +468,25 @@ Home -> Environments -> kafka-with-dotnet -> cluster_0 -> Topics
466468

467469
<img width="550" alt="image" src="https://github.com/akhanalcs/dotnet-kafka/assets/30603497/974b3b19-fa64-4402-8e40-8b2b3b48cfc1">
468470

471+
## Serialization & Deserialization
472+
The message producer is created by providing two types.
473+
```cs
474+
new ProducerBuilder<TypeofKey, TypeofValue>(config)
475+
```
476+
The first type represents the Key of the message while the second is for the Value.
477+
These types can be simple types, such as strings or integers, but they can also be more complex types like a custom class or struct.
478+
479+
However, Kafka itself doesn't directly understand these types, it just operates with blobs of data in byte form. This implies that we need to convert our data into an array of bytes before sending it to Kafka if it is a complex object.
480+
481+
<img width="650" alt="image" src="https://github.com/akhanalcs/dotnet-kafka/assets/30603497/528a11e9-a910-4ffa-b6ae-afe2e4997195">
482+
483+
To register a serializer for the message **value**, we use the `SetValueSerializer` method on the ProducerBuilder.
484+
For eg:
485+
```cs
486+
new ProducerBuilder<string, Biometrics>(producerConfig)
487+
.SetValueSerializer(new JsonSerializer<Biometrics>(schemaRegistry))
488+
.Build();
489+
```
469490

470491

471492

0 commit comments

Comments
 (0)