How to get an actorSystem current remote endpoint url?

784 views
Skip to first unread message

Brice Figureau

unread,
Jun 1, 2012, 11:38:12 AM6/1/12
to akka...@googlegroups.com
Hi all,

I'm back to a project using now akka 2.0.1 (last time I was working on
this, the project was using akka 2.0-M3).

This system registers actor system remote endpoint into zookeeper, so
that other nodes knows how to reach this actor system. To get the actor
system url, I was doing:

...
val system = ActorSystem("MySystem", config)
val url = (system / "").toString
...

Back in 2.0-M3 this used to return an ActorPath containing the current
actor system endpoint.

Now, in 2.0.1, it returns a local url:
akka://MySystem/user/

Using:
(system / "").toStringWithAddress(Serialization.currentTransportAddress.value)

only returns null (presumably Serialization.currentTransportAddress.value is null).

I checked everything is correctly configured, and akka prints this when starting:
[INFO] [06/01/2012 17:20:58.19] [main] [ActorSystem(MySystem)] REMOTE: RemoteServerStarted@akka://MySystem@localhost:2551

I have the feeling that Serialization.currentTransportAddress is lazily
filled when an actor is inserted into the ActorSystem. The problem is
that my attempt to register the system in zookeeper is done too early.

So what's the proper way nowadays to get the correct (remote) url of an actor system?
Or should I compute it myself (which of course is easy)?

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

√iktor Ҡlang

unread,
Jun 1, 2012, 12:22:07 PM6/1/12
to akka...@googlegroups.com

Hi Brice,

I answered this exact question on the ML less than 6h ago. Please search the archive prior to posting - it saves time for everyone.

Thanks,
V

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

Brice Figureau

unread,
Jun 1, 2012, 1:58:37 PM6/1/12
to akka...@googlegroups.com
On 01/06/12 18:22, √iktor Ҡlang wrote:
> I answered this exact question on the ML less than 6h ago. Please search
> the archive prior to posting - it saves time for everyone.

Fair enough :)

So I did my homework and I _think_ you're mentioning the following thread:
https://groups.google.com/group/akka-user/browse_thread/thread/77688c45b75cc9f3

The whole thread basically says that we shouldn't try to get the actor
path by ourselves, we should serialize it. That's good, unless like me
you don't yet have any actors, or you just want to expose a given
ActorSystem (and the rest of your system just knows the path of the
running actors it wants to contact by convention or other means).

Then your last answer to the thread is what I tried by myself, let me
paste my original message again:
> (system / "").toStringWithAddress(Serialization.currentTransportAddress.value)
> only returns null (presumably Serialization.currentTransportAddress.value is null).

I believe I'm encountering a chicken and egg problem here. The
currentTransportAddress is not defined yet because the ActorSystem is
not yet "started" (understand there is no actors running inside yet, or
the remote part has not yet been used), because my application at the
time it registers itself in zookeeper is still initializing. Yet I have
to "export" this ActorSystem address to the exterior world before some
other dependent parts get initialized that will in turn create the actors.

For the moment I fixed the problem by computing this url myself (the
format is known), but that feels somewhat clumsy.

So, let me rephrase my original question: how do I make sure the remote
part is initialized so that I can get access to the transport address value?

Thanks in advance,

√iktor Ҡlang

unread,
Jun 1, 2012, 2:41:29 PM6/1/12
to akka...@googlegroups.com
On Fri, Jun 1, 2012 at 7:58 PM, Brice Figureau <bric...@daysofwonder.com> wrote:
On 01/06/12 18:22, √iktor Ҡlang wrote:
> I answered this exact question on the ML less than 6h ago. Please search
> the archive prior to posting - it saves time for everyone.

Fair enough :)

Fair is how I roll ;-)
 

So I did my homework and I _think_ you're mentioning the following thread:
https://groups.google.com/group/akka-user/browse_thread/thread/77688c45b75cc9f3

The whole thread basically says that we shouldn't try to get the actor
path by ourselves, we should serialize it. That's good, unless like me
you don't yet have any actors, or you just want to expose a given
ActorSystem (and the rest of your system just knows the path of the
running actors it wants to contact by convention or other means).

Then your last answer to the thread is what I tried by myself, let me
paste my original message again:
> (system / "").toStringWithAddress(Serialization.currentTransportAddress.value)
> only returns null (presumably Serialization.currentTransportAddress.value is null).

I believe I'm encountering a chicken and egg problem here. The
currentTransportAddress is not defined yet because the ActorSystem is
not yet "started" (understand there is no actors running inside yet, or
the remote part has not yet been used), because my application at the
time it registers itself in zookeeper is still initializing.

currentTransportAddress is available during serialization over the remote transport.
As there might be multiple possible remote transports active at the same time in the future,
you'll have to decide what address you'll publish to the outside.

If you follow the example in the previous thread, you'll see how it can be implemented using an Extension.
If you then list that Extension amongst the extensions to be loaded at startup, I'd be more than surprised if you couldn't get the address by then already.
 
Yet I have
to "export" this ActorSystem address to the exterior world before some
other dependent parts get initialized that will in turn create the actors.

For the moment I fixed the problem by computing this url myself (the
format is known), but that feels somewhat clumsy.

So, let me rephrase my original question: how do I make sure the remote
part is initialized so that I can get access to the transport address value?

See answer above.
 
Cheers,


Thanks in advance,
--
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.




--
Viktor Klang

Akka Tech Lead
Typesafe - The software stack for applications that scale

Twitter: @viktorklang

√iktor Ҡlang

unread,
Jun 4, 2012, 4:13:31 AM6/4/12
to akka...@googlegroups.com
Hi Jed,

On Mon, Jun 4, 2012 at 9:39 AM, Jed Wesley-Smith <jed.wes...@gmail.com> wrote:
None of this is at all clear. We have a similar requirement. A central actor is contacted by remote agent VMs. We need to track the address of the remote system, but the sender is a local actor. We can transiently communicate with the remote via that sender reference, but it doesn't persist and we can't use the Address part for instance as an identifier/discriminator value.

"doesn't persist" makes me wonder how you're persisting it. When you manually serialize an ActorRef you need to provide the Address if it's local, as the address could change.
 

To put is simply, all we need is a way to dereference the remote sender's Address.

Have you've tried actorRef.path.address?
 
It is quite surprising that a remote actor's Address (when a sender) is not the remote actor's address.

May we know which address you expect and which one you get?
 

All help appreciated, we've wasted a lot of time on this so far.

May I interest you in the Typesafe Subscription, which includes Akka support?


Cheers,

 

On Saturday, 2 June 2012 04:41:29 UTC+10, √ wrote:
--
Viktor Klang

Akka Tech Lead
Typesafe - The software stack for applications that scale

Twitter: @viktorklang

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

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.

√iktor Ҡlang

unread,
Jun 4, 2012, 5:41:32 AM6/4/12
to akka...@googlegroups.com


On Mon, Jun 4, 2012 at 11:16 AM, Jed Wesley-Smith <jed.wes...@gmail.com> wrote:


On Monday, 4 June 2012 18:13:31 UTC+10, √ wrote:
Hi Jed,


On Mon, Jun 4, 2012 at 9:39 AM, Jed Wesley-Smith wrote:
None of this is at all clear. We have a similar requirement. A central actor is contacted by remote agent VMs. We need to track the address of the remote system, but the sender is a local actor. We can transiently communicate with the remote via that sender reference, but it doesn't persist and we can't use the Address part for instance as an identifier/discriminator value.

"doesn't persist" makes me wonder how you're persisting it. When you manually serialize an ActorRef you need to provide the Address if it's local, as the address could change.
 
We save a reference to remote actors in memory, the last seen value gets all the traffic. This is for a cluster controller where each node registers with it.

Ok, then you're not persisting it, merely keeping references around, did I get that right?
 

To put is simply, all we need is a way to dereference the remote sender's Address.

Have you've tried actorRef.path.address?
 
Yep, please see the separate post on it, we should move there.

Agreed, let's continue there.
 

It is quite surprising that a remote actor's Address (when a sender) is not the remote actor's address.

May we know which address you expect and which one you get?

Address(akka, dooby.atlassian.com, port, whatever) vs Address(akka, localhost, port, whatever)

Then you'll need to provide "dooby.atlassian.com" in the "hostname" field of your remote configuration.
 
 
 

All help appreciated, we've wasted a lot of time on this so far.

May I interest you in the Typesafe Subscription, which includes Akka support?


I put in a request for pricing, we'll see. At the moment we're in proof of concept stage (which of course is when you need all the support ;-)

That's a very fair observation ;-)
 

thanks mate for the quick replies,

Cheers mate,

 
jed. 

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

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