A simple way to Customize Kryo Serializer for Akka Actors in Scala

Table of contents
Reading Time: < 1 minute

Kryo is a fastest and efficient way to do serialization. It is more efficient than Java serialization – both in size and speed.

I am working on a Scala_Lift_Akka based project, where I have to implement serializer for Akka Actor’s remoting. Since Kryo is fast, efficient and easy to use, so I decided to implement Kryo in my project for serialization.

I implemented Romix’s kryo-based serialization library, which is excellent and easy to use.

Since above library is not compatible with Scala 2.10, so I used Akka-Kryo-Serializer_with Scala 2.10.

This kryo-based serializer supports all scala classes such as Option, Tuple, Enumeration etc. If you are using any other types except Scala types, such as net.liftweb.common.Box then you need to customize this serializer.

I have added a custom serailizer of net.liftweb.common.Box for my scenario. If you have such scenario, where you need to serialize other data-types except Scala types, then you would have to add serializer for that data type in below manner:

After that, you have to give reference of this serializer in ‘getKryo’ method of ‘KryoSerializer.scala’
by adding

Above approach works well for my scenario. If you have any better approach, please suggest.
Your suggestion would be highly appreciable.

Written by 

Ayush is the Sr. Lead Consultant @ Knoldus Software LLP. In his 10 years of experience he has become a developer with proven experience in architecting and developing web applications. Ayush has a Masters in Computer Application from U.P. Technical University, Ayush is a strong-willed and self-motivated professional who takes deep care in adhering to quality norms within projects. He is capable of managing challenging projects with remarkable deadline sensitivity without compromising code quality.

Discover more from Knoldus Blogs

Subscribe now to keep reading and get access to the full archive.

Continue reading