I have a kafka message in one kafka topic. One of the keys of this message key=ID
and value of that key is value=12345678910111213141
.
Type of this value is integer
. I want to convert the type to string
.
Currently am doing this in some hacky way:
Is there an easier way to do this?
PS: Don't have the access to the first producer which sends the message as integer
.
If I understand your question correctly, this will not be possible. As far as Kafka is concerned, all data is stored as Bytes and Kafka does not know which Serializer was used to generate the byte code.
Therefore, you can only deserialize the value in the same way as it was serialized by the Producer. As I understand, this was done using a Integer Serializer. But as you do not have acces to the Producer, you have no chance but reading it as an Integer and converting it to a String afterwards.