masesgroup / KNet

KNet is a comprehensive .NET suite for Apache Kafka™ providing all features: Producer, Consumer, Admin, Streams, Connect, backends (ZooKeeper and Kafka)
https://knet.masesgroup.com/
Apache License 2.0
38 stars 6 forks source link

Check if serialization done from .NET needs a reverse byte order to be compatible with Apache Kafka #436

Closed masesdevelopers closed 4 months ago

masesdevelopers commented 7 months ago
          It is possible to add a property, named `UseKafkaClassForSupportedTypes` with default value set to `false`, to decide which kind of serializer use:
Apache Kafka CLR (source from GitHub)
```java public class IntegerSerializer implements Serializer { public byte[] serialize(String topic, Integer data) { if (data == null) return null; return new byte[] { (byte) (data >>> 24), (byte) (data >>> 16), (byte) (data >>> 8), data.byteValue() }; } } ``` ```c# public static byte[] GetBytes(int value) { byte[] bytes = new byte[sizeof(int)]; Unsafe.As(ref bytes[0]) = value; return bytes; } ```

Originally posted by @masesdevelopers in https://github.com/masesgroup/KNet/issues/435#issuecomment-1984967518