Quantcast
Channel: Apache Timeline
Viewing all articles
Browse latest Browse all 5648

Clarification about Custom Encoder/Decoder for serialization

$
0
0
Hi All,

I wanted to get some clarification on Kafka's Encoder/Decoder usage.

Lets say I want to implement a custom Encoder.

public class CustomMessageSerializer implements Encoder<MyCustomObject> {

@Override
public byte[] toBytes(String arg0) {
// serialize the MyCustomObject
return serializedCustomObject ;

now in my producer properties I can set serializer.class to
CustomMessageSerializer

Now, i presume that when Kafka is ready to send the message, it will run
the message through the CustomMessageSerializer.

My question is - for each message (list of messages) that is to be sent,
does a new instance of CustomMessageSerializer instantiated, or is it that,
it instantiates the CustomMessageSerializer once, and calls toBytes(...)
for every message....?

Also, as a side note does Kafka support Kryo serializer?

Regards,
-Jacob

Viewing all articles
Browse latest Browse all 5648

Trending Articles