[Akka 2.4.7] + [Play 2.5] Inject Serialization Bindings Config Programmatically??

75 views
Skip to first unread message

kraythe

unread,
Jun 13, 2016, 3:50:20 AM6/13/16
to Akka User List
Greetings, 

I have a large map of serialization bindings basically in a big map where type ids are defined that I would like to inject into the config at startup but I have been unable to figure out how to do this. These serialization bindings are used by 4 or 5 pieces of tech we have in the stack so defining them programmatically is much more efficient. That way if we add one to one place its changed for everywhere. Is there any way I can do this? 

On a related note, is it possible to tell the Akka system to not use Java serialization at all but rather the Kryo serializer extension that I have integrated. I have had bad experiences with Java serialization when it comes to performance and would like to deprecate it completely.

Thanks as usual. You are all so helpful. Best community ever!

Guido Medina

unread,
Jun 13, 2016, 4:10:01 AM6/13/16
to Akka User List
Yes, just change the "java.io.Serializable" binding from "java" to "kryo", I'm not at home so can't look the exact key nor copy & paste my config section for that.
That way any object that implements serializable will be serialize with Kryo, objects that don't implement Serializable you will have bind explicitly.

HTH,

Guido.

Guido Medina

unread,
Jun 13, 2016, 4:10:50 AM6/13/16
to Akka User List
To look for that key in the config open reference.conf of akka-remote-....2.4.7.jar

Guido Medina

unread,
Jun 13, 2016, 4:16:38 AM6/13/16
to Akka User List
ahh, sorry, yes, you can have a static.conf, say, your static section of the config and programmatically you can build your config and include a static file as a resource,
that's kind of way of mixing static conf with config objects, see Merging config trees: https://github.com/typesafehub/config#merging-config-trees

kraythe

unread,
Oct 28, 2016, 5:06:52 PM10/28/16
to Akka User List
I am wondering if this would use the same bindings for all the default JDK types or if that would be another issue. 

Guido Medina

unread,
Oct 28, 2016, 7:08:20 PM10/28/16
to Akka User List
The default bindings for Java = "java.io.Serializable",
that is also why when you register:

serializers.java = "com.romix.akka.serialization.kryo.KryoSerializer"

you are basically covering all standard Java classes.
The only thing you would need to do for your own classes is make them implement Serializable.

HTH,
Guido.
Reply all
Reply to author
Forward
0 new messages