Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configuring akka serialization in Play 2.0 framework #12

Closed
tovbinm opened this issue Apr 11, 2012 · 3 comments
Closed

Configuring akka serialization in Play 2.0 framework #12

tovbinm opened this issue Apr 11, 2012 · 3 comments

Comments

@tovbinm
Copy link

tovbinm commented Apr 11, 2012

Hi guys,

I'd like to configure protobuf to be the default serialization for my messages.
Here what I do in attempt to make it happen:

import akka.actor._
import akka.pattern.ask
import akka.serialization._
import akka.util._
import play.api._
import play.libs.Akka
import akka.util.Timeout

object Engine {
implicit val timeout = Timeout(1 second)
val ngin = Akka.system.actorOf(Props[Engine])
}

class Engine extends Actor {
val ser = SerializationExtension(context.system)
override def preStart() = {
println("Got %s serializer for %s"
.format(ser.findSerializerFor(classOf[java.lang.String]).getClass().getName(),
classOf[java.lang.String].getName()))
}
def receive = { ... }
}

While my application.conf file contains the following section:

play { akka { actor {
serializers { proto = "akka.serialization.ProtobufSerializer" }
serialization-bindings { "java.io.Serializable" = proto
"java.lang.String" = proto }
} } }

Though I always get JavaSerializer: "Got
akka.serialization.JavaSerializer serializer for java.lang.String"
What am I doing wrong?!

-Matthew

@havocp
Copy link
Collaborator

havocp commented Apr 12, 2012

"java.io.Serializable" = proto doesn't look right, it should be =${proto} with the ${} maybe?

You might try setting some other random thing in the config file (just make up a setting) that doesn't involve the SerializationExtension stuff, and be sure play.akka is even used. For example set play.akka.hello="Hi", then print context.system.settings.config.getString("akka.hello")

@tovbinm
Copy link
Author

tovbinm commented Apr 12, 2012

Thanks!! This was indeed simple ;)

Removing play {...} solves the issue, as follows:

akka { actor {
serializers { proto = "akka.serialization.ProtobufSerializer" }
serialization-bindings { "java.io.Serializable" = proto
"java.lang.String" = proto }
} }

This document should be updated : http://www.playframework.org/documentation/2.0/AkkaCore

@havocp
Copy link
Collaborator

havocp commented Apr 13, 2012

This is kind of weird, I would expect that the play{} should be there. hard to debug without a full test case though.
I'm going to close the issue here because I don't think there's an action to take in the config lib code/docs (?) but it might be worth asking the Play guys what is going on, though sending them a small test app might be needed. Thanks

@havocp havocp closed this as completed Apr 13, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants