These are chat archives for akkadotnet/akka.net

31st
Oct 2018
to11mtm
@to11mtm
Oct 31 2018 03:09
@tkeegan-ealink In scenarios like that I would consider having a %Whatever%Command Validator, either as an Actor earlier in the pipeline or as something that could be Asked. The former is probably the more performant solution and may be cleaner for opportunities such as then deciding that your bad commands go to some sort of Invalid%Whatever%CommandHandler that does reporting/messaging back to user/etc.
Bartosz Sypytkowski
@Horusiath
Oct 31 2018 07:53
@heyixiaoran is your ruter a clustered one? Also if you want to send message from actor on one node to an actor on another node, you need to include absolute actor path (including node address). You can get info about all nodes using Akka.Cluster.Cluster plugin - it contains the current state of the nodes in the cluster, what roles have they assigned and allows you to subscribe to in order to update information about joining/removed nodes.
@managerger are you adding cancellation token or timeout to your Ask? If not, they can stuck waiting for response forever.
Blue
@heyixiaoran
Oct 31 2018 08:55
@Horusiath Yes. They're cluster . I set three seed-nodes . no logic code .just as seed-nodes to keep system no crush. Then run a client1 node to add this system and config routees.paths = ["/user/client2"]. Run a client2 node . The client2 node receive one message when the client1 node send two message. always loss one message and the r.Result.Members.Count() is 2. Why it's 2 not1? How can I make client2 node receive all messages? Thx
Blue
@heyixiaoran
Oct 31 2018 09:19
image.png
managerger
@managerger
Oct 31 2018 11:51
@object Sorry for confusion. I've meant that invocation code actorRef.Ask(message) hangs forever.
@Horusiath I've added timeout to the ask and I'm getting TimeoutException but the real exception is never comes back to my invocation code.
My model looks like that:
1) Invoke var task = await _actorRef.Ask(message) in my controller action
2) I use Forward everywhere in order to sent message to the final destination actor
3) If everything is ok I get result back
4) In case of exception I get TimeoutException, but I need to return real exception to the invocation code
await Ask->Forward->Forward->ReceiveAsync{ await AsyncOperation(message)}
tkeegan-ealink
@tkeegan-ealink
Oct 31 2018 12:50
@managerger I am also starting with Akka.net and core ... Here is my understanding (i am sure that others will correct me if i am wrong). When you do an Ask, this is a blocking action and a response is expected .... so if the ask does not get a reply send to it, then it would sit there forever.
Now I understand that when an exception is thrown, the supervisor will try to deal with it .... and if it cant then it will move to its supervisor (and so on), but typically this would mean that that the sender is never going to get the reply that it expects. So you would need to catch the exception somewhere (either in the supervisor, or in the restart of the actor, and use that as the place to send a message to the sending actor).
If any of this is incorrect,i hope someone will correct me :)
tkeegan-ealink
@tkeegan-ealink
Oct 31 2018 12:55
@to11mtm thanks .. actually what i am trying to do is to have (say) a Personnel Register Actor that will maintain people ... this would then have a Repository, that it would pass to another actor that would be responsible for updating the repository from the Persitent Query feed. The Personnel Register would then be able to use the same repository to do any lookup on the registry to check for duplications in a peson's Id, before passing it the Persistent Person Actor.
Does this sound like a reasonable approach to you?
managerger
@managerger
Oct 31 2018 13:08
@tkeegan-ealink Thank you a lot! I've just realized the same. And I've tried to deal with exception message in PreRestarthook. Everything is fine except of the one thing -> we are forced to send exception as a message. I mean, we can't throw it in the invocation code as far as I understand but we can only get a text message and
somehow process it.
tkeegan-ealink
@tkeegan-ealink
Oct 31 2018 13:13
@managerger you might want to look at having a base message class that allows you to send a success indicator, along with any error message/stack trace .... then you would have all your messages derived from that.
Yes I think that the PreRestart hook would be the place to put it ... since the Actor itself would be naturally given the opportunity to restart, and it should probably be the best judge of the nature of the error.
But it might also be possible to put it into the supervisor (if there is one)
managerger
@managerger
Oct 31 2018 13:22
@tkeegan-ealink Yeah, thank you! Deeply appreciate