Serializing actor behavior in Akka 1.3

25 views
Skip to first unread message

Samira Tasharofi

unread,
May 13, 2012, 3:12:26 PM5/13/12
to Akka User List
Hi all,

In Akka 1.3, I have a class named "CustomeActorRef" that extends
"ActorRef" and I use a factory to create an instance of
CustomeActorRef instead of ActorRef.

Inside CustomeActorRef, I override the method "invoke" to serialize
the actor behavior by the following code:

override def invoke(messageHandle: MessageInvocation): Unit = {
super.invoke(messageHandle)
if (this.hotswap.nonEmpty) {
var beh = this.hotswap.head
var stream = new java.io.ObjectOutputStream(new
java.io.FileOutputStream("behavior"))
stream.writeObject(beh)
}
}

But upon calling "writeObject" I am getting exception. Do you know how
I can serialize the actor behavior?

Thanks,
Samira

Jonas Boner

unread,
May 15, 2012, 10:00:10 AM5/15/12
to akka...@googlegroups.com
It depends on what the PartialFunction closes over. Impossible to
answer or implement generically.
> --
> You received this message because you are subscribed to the Google Groups "Akka User List" group.
> To post to this group, send email to akka...@googlegroups.com.
> To unsubscribe from this group, send email to akka-user+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/akka-user?hl=en.
>



--
Jonas Bonér
CTO
Typesafe - The software stack for applications that scale
Phone: +46 733 777 123
Twitter: @jboner

Samira Tasharofi

unread,
May 15, 2012, 3:05:10 PM5/15/12
to Akka User List
Jonas,
My problem is solved. I needed to make the Actor class Serializable.
Thanks a lot for your reply.

Regards,
Samira
> > For more options, visit this group athttp://groups.google.com/group/akka-user?hl=en.
Reply all
Reply to author
Forward
0 new messages