Kryo deserialization in other programming languages

189 views
Skip to first unread message

Saurav Bhagat

unread,
Jun 3, 2021, 7:36:33 AM6/3/21
to kryo-users
Hi all, 

My backend Java application uses kryo to serialize data before publishing it to Kafka, now I'm writing consumer application in javascript. How can I deserialize it?

Is there any kryo package or any guide on how can I write a custom deserializer?

Thanks.

Thomas Heigl

unread,
Jun 3, 2021, 8:29:39 AM6/3/21
to kryo-...@googlegroups.com
Hi Saurav,

There is no Kryo JS port. Since there is no formal specification for Kryo's protocol, writing a client in another language is quite difficult. You would have to go through all Kryo serializers used to encode your data and replicate the logic in JS.

Is there any chance you can parse the data and convert it to JSON or any other format before passing it to your JS consumer?

Thomas

--
You received this message because you are subscribed to the "kryo-users" group.
http://groups.google.com/group/kryo-users
---
You received this message because you are subscribed to the Google Groups "kryo-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kryo-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kryo-users/d121c4df-57d6-4a5d-8794-822c137c2b77n%40googlegroups.com.

Saurav Bhagat

unread,
Jun 3, 2021, 8:50:19 AM6/3/21
to kryo-users
Hi Thoms, 
Thanks for the quick response. 
serialized data is getting published to kafka, and since JS consumer is subscribed to that kafka topic as soon as data comes into the topic, the consumer will receive that data.
I cannot think of any other way apart from using JSON serializer at the source itself maybe?
Am I missing something?

Saurav

Thomas Heigl

unread,
Jun 3, 2021, 9:29:20 AM6/3/21
to kryo-...@googlegroups.com
I cannot think of any other way apart from using JSON serializer at the source itself maybe?

Kryo isn't really intended for cross-platform use. In your case it would probably make more sense to use protobuf, messagepack or if size/speed is not that important even JSON itself.

Alternatively, you could create a consumer in Java that deserializes the Kryo data, re-encodes it in JSON and publishes it again to another topic that can be consumed by JS.

Thomas

Saurav Bhagat

unread,
Jun 3, 2021, 9:36:14 AM6/3/21
to kryo-users
Yeah,
Thanks for the suggestions. I would check with my team on which of these can fit our case.

Thanks,
Saurav
Reply all
Reply to author
Forward
0 new messages