How to get the sender actor with 'ask'?

565 views
Skip to first unread message

Brice Figureau

unread,
Dec 6, 2011, 5:33:55 AM12/6/11
to akka...@googlegroups.com
Hi,

In the event where I use:

actor ? Message

On the receiving side, the channel is a "future" channel.
Is there a way to get access to the sender actor ActorRef (mainly to
keep it handy to send it other messages without being first sent a
message from 'actor')?

Let me explain better my use case (which might be plain stupid, so
please do not hesitate to point the faults):

I have two remote actors, A and B. B has been "discovered" by other
means than akka itself.
A will introduce itself to B first by sending to B a message, and B will
capture A ActorRef and keep it handy. Later, B might need to send back
asynchronously other messages and will use this ActorRef.

But I'd like anyway that first message sent (used by B to know who/where
is A) to fail in case of a timeout (either from B no response or
communication failure), so I'm inclined to use the "ask" semantics.
Except I fail to see how I can get the A ActorRef from B.
I could include A ActorRef into my own message (protobuf based), but I
fail to see how I can serialize/deserialize this information.

Thanks for any reponse!
--
Brice Figureau
My Blog: http://www.masterzen.fr/

rkuhn

unread,
Dec 6, 2011, 5:46:57 AM12/6/11
to akka...@googlegroups.com

If you can send from A to B using “ask”, then by all means include A’s reference in the message: it will work. And it looks like the correct thing to do with your requirements (although you could also split it up in two sends from A, one for verification of B plus one for registering future interest in communications with B).
 

Thanks for any reponse!


You’re welcome!

Regards,

Roland

√iktor Ҡlang

unread,
Dec 6, 2011, 5:52:08 AM12/6/11
to akka...@googlegroups.com
You can also send the reference in a message.

Cheers,


--
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To view this discussion on the web visit https://groups.google.com/d/msg/akka-user/-/Skt-ej7npj0J.

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.



--
Viktor Klang

Akka Tech Lead
Typesafe - Enterprise-Grade Scala from the Experts

Twitter: @viktorklang

Brice Figureau

unread,
Dec 6, 2011, 5:52:50 AM12/6/11
to akka...@googlegroups.com

My problem is that my messages are protobuf based and actors are
remote.
I fail to see how to "reference" my A actor in my protobuf message.

> And it looks like the correct thing to do with your requirements
> (although you could also split it up in two sends from A, one for
> verification of B plus one for registering future interest in
> communications with B).

Yes, I believe that might be the correct solution for my test case.

Thanks for your prompt answer!

√iktor Ҡlang

unread,
Dec 6, 2011, 5:55:45 AM12/6/11
to akka...@googlegroups.com

The docs on serialization is a good start: http://akka.io/docs/akka/1.3-RC2/scala/serialization.html
 

> And it looks like the correct thing to do with your requirements
> (although you could also split it up in two sends from A, one for
> verification of B plus one for registering future interest in
> communications with B).

Yes, I believe that might be the correct solution for my test case.

Thanks for your prompt answer!

You're more than welcome.

Cheers,

 
--
Brice Figureau
My Blog: http://www.masterzen.fr/

--
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.

Reply all
Reply to author
Forward
0 new messages