These are chat archives for akkadotnet/akka.net

28th
Oct 2016
Jay DeBoer
@jaydeboer
Oct 28 2016 06:17
I just wanted to check back in. I figured this out. I will end up making a PR to update the docs. I was missing a line or two in the HOCON. :)
Arjen Smits
@Danthar
Oct 28 2016 09:40
:+1:
Peter Bergman
@peter-bannerflow
Oct 28 2016 09:44

Question on routers, I have a cluster enabled round-robin-group router with the following config:

/workerRouter {
  router = round-robin-group
  nr-of-instances = 10
  routees.paths = [
      "/user/worker0",
      "/user/worker1",
      "/user/worker2",
      "/user/worker3",
      "/user/worker4",
      "/user/worker5",
      "/user/worker6",
      "/user/worker7",
      "/user/worker8",
      "/user/worker9"
    ]
  cluster {
      enabled = on
      allow-local-routees = off
      use-role = worker
  }
}

So this works fine when I have one node joined the cluster with role worker. However, I am not sure what will happend if I join another machine with the workerrole (running the same code as well). Would the router seamlessly just round robin messages to the routees on the new role as well?

I am running some tests right now were I only see utilization on one of the nodes that has joined as worker, so I guess that messages are not round robined over all routees on all machines?
So I guess my real question is, what do I need to do in order for the router to round robin messages to all routees on all nodes?
ChaosD
@ChaosD
Oct 28 2016 10:29
Is it possible to have custom settings for actors in akka's HOCON? something like akka.actors.deployment./worker.my-setting = test ? if so (i tried), how do i access it in my worker actor?
Peter Bergman
@peter-bannerflow
Oct 28 2016 11:07
@ChaosD If you have access to the AkkaConfigurationSectionobject, then I think you can do something like GetString("akka.actor.deployment./worker.my-setting") on it
Bartosz Sypytkowski
@Horusiath
Oct 28 2016 11:22
@ChaosD you can set in HOCON whatever you want. From particular actor you can access that path by var configSection = Context.System.Settings.Config.GetConfig(<config path>)
Nicola Atorino
@NicolaAtorino
Oct 28 2016 12:00
Hi Everyone. A quick question : is it possible to have more than one singleton actor in an actor system ? I want two actors to act as singleton in my cluster, but the Hocon Configuration akka.cluster.singleton seems to not accept an array, so i cannot configure two actors as singleton. Is there a way?
Andrey Leskov
@andreyleskov
Oct 28 2016 12:03
You can have 1 singleton with 2 children inside
Nicola Atorino
@NicolaAtorino
Oct 28 2016 12:04
I got it. This way i wan;t be able to split them on different roles tough. Well, better than nothing
thank you
Nicola Atorino
@NicolaAtorino
Oct 28 2016 12:11
another thing : the singleton i am using doe not seem to be very 'reliable' : sometimes it works, sometimes it doesn't. It does not receive the messages, and the only feedback i receive is a log with the proxy forwarding the message to it. Also, the system is taking a lot of time to identify the singleton in the cluster. Are those kind of issue common, and is there a way to address these problem?
Bartosz Sypytkowski
@Horusiath
Oct 28 2016 12:12
@NicolaAtorino first question would be what version of Akka.Cluster.Tools are you using and what are you going to use singleton for
Nicola Atorino
@NicolaAtorino
Oct 28 2016 12:13
the version is the 1.1.2.30-beta
regarding the usage, the singleton is a 'router' that needs to receive messages from different sources (other actors, a remote API) and then spawn specific children based on those messages, to which he will then route the subsequent information.
Bartosz Sypytkowski
@Horusiath
Oct 28 2016 12:19
maybe cluster.sharding would be a valid case for that too. Anyway: regarding singleton, singleton will be intantiated only on the nodes where you've explicitly created it using ClusterSingletonManager and you should contact it using either returned reference or through ClusterSingletonProxy (which will discover on which node singleton has been recreated and buffer messages in the meantime, but will never serve as a spawning point for a singleton itself)
so if you've lost your singleton node and have no more nodes with that ClusterSingletonManager setup, singleton will never respawn - maybe that's your case
Vlad Kosarev
@vladkosarev
Oct 28 2016 12:21
hey guys, would anyone have any clue why actorSystem.Terminate() takes a couple of orders of magnitude longer if we run our tests in Debug mode vs Run mode?
ChaosD
@ChaosD
Oct 28 2016 12:21
@Horusiath @peter-bannerflow , thank you, i will gibe it a shot. i thought, i could configure the actors depending on their path in the network, when i started reading about HOCON. Kind of like how the deployment settings are "scoped" by the paths.
Nicola Atorino
@NicolaAtorino
Oct 28 2016 12:26
@Horusiath i am using clusterSingletonProxy for every communication with the singleton
Peter Bergman
@peter-bannerflow
Oct 28 2016 13:02
Never mind my earlier question. I had missed to update the nr-of-instancesproperty.
ChaosD
@ChaosD
Oct 28 2016 13:12
It does not seem to work... onside my actor, i use ConfigurationFactory.Load() to access the config (loads fine, my custom setting included) but when i try to load my setting via full (or patial) path, it just returns the default value.
Bartosz Sypytkowski
@Horusiath
Oct 28 2016 13:15

@ChaosD if you have following hocon section:

akka {
  actors {
    my-actor {
      key = "value"
    }
  }
}

you can simply get that property from within of the actor by:

var myActorConfig = Context.System.Settings.Config.GetConfig("akka.actors.my-actor");
var keyValue = myActorConfig.GetString("key");
ChaosD
@ChaosD
Oct 28 2016 13:19
this works nicely. my problem was, that i was getting the whole config in the beginning. Thanks for your sample
Gregorius Soedharmo
@Arkatufus
Oct 28 2016 13:21
how do you load and merge custom hocon into the system config? can you have 2 separate .config files with different <akka> tags and different hocons?
ChaosD
@ChaosD
Oct 28 2016 13:21
if i want this to mix well with the existing deployment config, could i use the actor's path to load configurations depending on where they are deployed?
Gregorius Soedharmo
@Arkatufus
Oct 28 2016 13:23
thanks, i was loading them manually using streams... it was a mess, i'll check the link
ChaosD
@ChaosD
Oct 28 2016 13:33
nevermind my last idea, it does not work. Is there any way i can user the existing actor configuration system (paths, wildcards, etc) to sneak in my own settings for actors?
Damian Reeves
@DamianReeves
Oct 28 2016 14:04
I'm having a senior moment and can't recall how to set the actor types that are created for a pool router using config. How do I do that again?
Aaron Stannard
@Aaronontheweb
Oct 28 2016 14:04
@DamianReeves Props.Create(() => new MyActor()).WithRouter(FromConfig.Instance);
Damian Reeves
@DamianReeves
Oct 28 2016 14:05
That I know... but is there a way to get the type of MyActor from config?
Aaron Stannard
@Aaronontheweb
Oct 28 2016 14:05
nope
Props always has to be done in C# or F#
Damian Reeves
@DamianReeves
Oct 28 2016 14:05
lol... simple direct answer... I like it
Aaron Stannard
@Aaronontheweb
Oct 28 2016 14:05
since it's the instruction used to instantiate
Damian Reeves
@DamianReeves
Oct 28 2016 14:06
May be a case for DI, but I've avoided DI in Akka, because the API feels like ServiceLocator
Damian Reeves
@DamianReeves
Oct 28 2016 14:26
Does DistributedPubSub support delivery confirmations intrinsically or is this something I need to handle between my publishing and subscribing actors?
Aaron Stannard
@Aaronontheweb
Oct 28 2016 14:27
the latter
Damian Reeves
@DamianReeves
Oct 28 2016 14:28
cool. Do I need to worry about the Mediator in DistributedPubSub dieing, do I have any reason to need to DeathWatch it during normal operation?
Aaron Stannard
@Aaronontheweb
Oct 28 2016 14:29
that's a better question for @Horusiath
Gregorius Soedharmo
@Arkatufus
Oct 28 2016 14:32

@ChaosD

akka {
    actor {
        deployment {
            /someRouter {
                router = broadcast-group
                routees.paths = []
                nr-of-instances = 5 
                custom-string = "blah"
                custom-int = 666
            }
        }
    }
}
var config = akkaSystem.Settings.Config.GetConfig("akka.actor.deployment");
Console.Out.WriteLine(config.GetString("/someRouter.custom-string"));
Console.Out.WriteLine(config.GetInt("/someRouter.custom-int"));
Console.Out.WriteLine(akkaSystem.Settings.Config.GetString("akka.actor.deployment./someRouter.custom-string"));

works for me

ChaosD
@ChaosD
Oct 28 2016 14:39
yeah, this works for me, too. but what if instead of someRouter, i have /myRouter/someActor, /otherRouter/myActor or even /router/foo/*/bar ? wouldn't that mean that the actor reading the config always has to know where it is deployed (and match wildcards on its own)?
Gregorius Soedharmo
@Arkatufus
Oct 28 2016 14:42
well, the slashes are not parsed into separate hoconvalue... i think... so you can just pass the config in the actor constructor inside the props?
ChaosD
@ChaosD
Oct 28 2016 14:42
the idea was to piggyback on the existing actor deployment configuration. I'm not even sure if it is a good idea....
Gregorius Soedharmo
@Arkatufus
Oct 28 2016 14:43
unless you want to do a config lookup inside the actor in run time
ChaosD
@ChaosD
Oct 28 2016 14:44
props might be a good idea, my router can read the config and then distribute it to the workers via props
i'll take a look at this - thanks for your input!
Gregorius Soedharmo
@Arkatufus
Oct 28 2016 14:46
var config = akkaSystem.Settings.Config.GetConfig("akka.actor.deployment./workers");
var props = Props.Create<Worker>(config).WithRouter(FromConfig.Instance);
var actor = system.ActorOf(props, "workers");
something like that?
if you really want to do a config lookup during runtime, you can convert the deployment hoconvalues to a dictionary and do a lookup that way
Gregorius Soedharmo
@Arkatufus
Oct 28 2016 14:56
            var config = akkaSystem.Settings.Config.GetConfig("akka.actor.deployment");
            Dictionary<string, Config> configs = new Dictionary<string, Config>();
            foreach(var pair in config.AsEnumerable()) {
                configs[pair.Key] = new Config(new HoconRoot(pair.Value));
            }
you then pass the dictionary in Props into the worker constructor...
a bit hackish though
ChaosD
@ChaosD
Oct 28 2016 15:35
@Arkatufus , your first suggestion looks good, i'l lsave that for next week, when i get back to work. Thank you very much.
Gregorius Soedharmo
@Arkatufus
Oct 28 2016 15:36
(y)
Bartosz Sypytkowski
@Horusiath
Oct 28 2016 18:48
@DamianReeves I don't think, that normal dist pub/sub mediator will ever go down under normal conditions (if so, it will probably go down with the whole node).
Damian Reeves
@DamianReeves
Oct 28 2016 21:39
So I'm creating a IDependencyResolver implementation based on Microsoft.Extensions.DependencyInjection and I'm wondering what is the default registration I want to apply. The Autofac implementation seems to use Transient but the others seem to use the equivalent of Scoped.