Getting the remote path of an actor in 2.0-RC1

734 views
Skip to first unread message

smr

unread,
Feb 16, 2012, 10:18:56 AM2/16/12
to Akka User List
Hi!

I'm trying to get the actor remote path but the method actor.path()
returns the local path.

My akka version is 2.0-RC1 and my configuration are:

akka {
actor {
provider = "akka.remote.RemoteActorRefProvider"
}

remote {
transport = "akka.remote.netty.NettyRemoteTransport"
netty {
hostname = "127.0.0.1"
port = 2552
}
}
}

The ActorSystem creation...

Config config = ConfigFactory.load().getConfig(configName);
ActorSystem system = ActorSystem.create(systemName, config);

And the actor creation...

ActorRef actor = system.actorOf(new Props(actorclass), name);
String path = actor.path().toString();


This configuration works with 2.0-M2 and 2.0-M3 (with the correct
transport class, of course), i.e. actor.path() returns the actor
remote path.

How can I get the remote path of an actor in 2.0-RC1?

Thanks!

Sonia

√iktor Ҡlang

unread,
Feb 16, 2012, 10:25:08 AM2/16/12
to akka...@googlegroups.com
Hi Sonia,

What problem are you trying to solve by using the external address?

Cheers,

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

smr

unread,
Feb 16, 2012, 10:53:22 AM2/16/12
to Akka User List
Hi Viktor,

I want to have a client that can invoke remote actors dynamically.
Therefore, I need to know the remote paths when the actors are
created.

Best regards,

Sonia
> > For more options, visit this group athttp://groups.google.com/group/akka-user?hl=en.

√iktor Ҡlang

unread,
Feb 16, 2012, 10:59:08 AM2/16/12
to akka...@googlegroups.com
Hi Sonia,

Just give the client the ActorRef?

Cheers,

> For more options, visit this group at http://groups.google.com/group/akka-user?hl=en.

smr

unread,
Feb 16, 2012, 11:15:42 AM2/16/12
to Akka User List
Hi,

Yes, I want to give the client the ActorRef returned by the actorFor
but for that, I need the remote path of the actor.

Thanks,

Sonia

On 16 feb, 16:59, √iktor Ҡlang <viktor.kl...@gmail.com> wrote:
> Hi Sonia,
>

√iktor Ҡlang

unread,
Feb 16, 2012, 11:27:51 AM2/16/12
to akka...@googlegroups.com
Hi!

On Thu, Feb 16, 2012 at 5:15 PM, smr <smatamor...@gmail.com> wrote:
> Hi,
>
> Yes, I want to give the client the ActorRef returned by the actorFor
> but for that, I need the remote path of the actor.

Your code looked like this:

ActorRef actor = system.actorOf(new Props(actorclass), name);
String path = actor.path().toString();

I assume your remote client is also an actor:

remoteClient.tell("this is your new buddy", actor)

Or, if this is not the case, I think you need to provide some more code.

Cheers,

> For more options, visit this group at http://groups.google.com/group/akka-user?hl=en.

smr

unread,
Feb 16, 2012, 1:33:43 PM2/16/12
to Akka User List
Hi Viktor,

I think that I haven't explained so good.

I don't create actors remotelly, I create the actors in the server
side and then I tell the client the remote path of them.

When I create an actor, in the server side, with remote support in 2.0-
M2 and 2.0-M4, the actor path is an remote path. But, when I create an
actor in version 2.0-RC1, the actor path is a local path. I'm using
the method actor.path() for get the actor path.

How I must recover the remote path of server side actor?

Thanks you,

Sonia


On 16 feb, 17:27, √iktor Ҡlang <viktor.kl...@gmail.com> wrote:
> Hi!
>

rkuhn

unread,
Feb 16, 2012, 1:57:31 PM2/16/12
to akka...@googlegroups.com
Hi Sonia,

while it is possible to obtain the remote address, you should not need it unless under very specific circumstances, most notably when serializing ActorRef yourself.

One thing you left out in the description of your scenario is how client and server communicate. If they just use Akka remoting, then the only thing you need is to send the ActorRef directly, no paths needed.

Regards,

Roland

√iktor Ҡlang

unread,
Jun 1, 2012, 7:27:50 AM6/1/12
to akka...@googlegroups.com


On Fri, Jun 1, 2012 at 12:42 PM, Andrea Corzani <acor...@gmail.com> wrote:
Hi Roland,
we really need the remote path of the actor, cause our problem is relative to serialization.
What is the way to retrieve it?


Cheers,
√ 
 

Thanks!

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

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

unread,
Jun 4, 2012, 7:39:07 AM6/4/12
to akka...@googlegroups.com
On Mon, Jun 4, 2012 at 9:46 AM, Jed Wesley-Smith
<jed.wes...@gmail.com> wrote:
> If I try something similar in Scala I get:
>
> [error] …/Agent.scala:36: method provider in trait ActorRefFactory cannot be
> accessed in akka.actor.ActorSystem
> [error]  Access to protected method provider not permitted because
> [error]  enclosing class class Agent in package distributed is not a
> subclass of
> [error]  trait ActorRefFactory in package actor where target is defined
> [error]
> (system.provider.asInstanceOf[RemoteActorRefProvider]).transport.address
>
> same thing with context.provider

system needs to be coerced to ExtendedActorSystem, which is why it's
done in an Extension.

Cheers,


>
> On Saturday, 2 June 2012 21:46:14 UTC+10, Andrea Corzani wrote:
>>
>> Thank you very much, it works!
>> inside an actor:
>>
>>             Address systemRemoteAddress;
>>             if (context().system().provider() instanceof
>> RemoteActorRefProvider) {
>>                 systemRemoteAddress = ((RemoteActorRefProvider)
>> context().provider()).transport().address();
>>             } else {
>>                 throw new UnsupportedOperationException("need
>> RemoteActorRefProvider");
>>             }
>>
>>             String actorRemoteAddress =
>> getSelf().path().toStringWithAddress(systemRemoteAddress);
>>
>> Il giorno venerdì 1 giugno 2012 13:27:50 UTC+2, √ ha scritto:
>>>
>>>
>>>
>>> On Fri, Jun 1, 2012 at 12:42 PM, Andrea Corzani  wrote:
>>>
>>>> Hi Roland,
>>>> we really need the remote path of the actor, cause our problem is
>>>> relative to serialization.
>>>> What is the way to retrieve it?
>>>
>>>
>>>
>>> http://doc.akka.io/docs/akka/snapshot/java/serialization.html#Serializing_ActorRefs
>>>
>>> Cheers,
>>> √
>>>
>>>>
>>>>
>>>> Thanks!
>>>>
>>>> Il giorno giovedì 16 febbraio 2012 19:57:31 UTC+1, rkuhn ha scritto:
>>>>>
>>>>> Hi Sonia,
>>>>>
>>>>> while it is possible to obtain the remote address, you should not need
>>>>> it unless under very specific circumstances, most notably when serializing
>>>>> ActorRef yourself.
>>>>>
>>>>> One thing you left out in the description of your scenario is how
>>>>> client and server communicate. If they just use Akka remoting, then the only
>>>>> thing you need is to send the ActorRef directly, no paths needed.
>>>>>
>>>>> Regards,
>>>>>
>>>>> Roland
>>>>
>>>> --
>>>
>>>
>>>
> --
> 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/-/DdumL7MkAnUJ.
Reply all
Reply to author
Forward
0 new messages