On Thu, Apr 23, 2015 at 4:35 AM, Chris Ridmann <[email protected]>
wrote:

> Hello,
>
> I'm using akka persistence and am serializing all of my events into JSON
> using the play-json library.  For the most part this has been smooth
> sailing, however I can't seem to figure how to do this with ActorRef's - it
> may not be possible with how I'm trying to do it.
>
> Here is what I have thus far:
>
>   implicit val actorRefFormat: Format[ActorRef] = new Format[ActorRef] {
>     def reads(json: JsValue): JsResult[ActorRef] = {
>       JsSuccess(Actor.noSender) // ???
>     }
>
>     def writes(o: ActorRef): JsValue = {
>       val identifier = Serialization.serializedActorPath(o)
>       Writes.StringWrites.writes(identifier)
>     }
>   }
>
>
>
>  It seems the `Writes` will work because it doesn't depend on having an
> `ActorSystem` in scope.  How would I do this for the `Read`?
>

Yes, you need the actor system for deserialization.
http://doc.akka.io/docs/akka/2.3.10/scala/serialization.html#Serializing_ActorRefs

If that is impossible you must rethink, and use a String and convert it to
an ActorRef at another layer.

/Patrik


>
> Thanks!
> -Chris
>
> --
> >>>>>>>>>> Read the docs: http://akka.io/docs/
> >>>>>>>>>> Check the FAQ:
> http://doc.akka.io/docs/akka/current/additional/faq.html
> >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
> ---
> You received this message because you are subscribed to the Google Groups
> "Akka User List" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/akka-user.
> For more options, visit https://groups.google.com/d/optout.
>



-- 

Patrik Nordwall
Typesafe <http://typesafe.com/> -  Reactive apps on the JVM
Twitter: @patriknw

-- 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: 
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>>      Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to