looking for a way to reliably send a message to self #6568
-
i'm looking for a way for an actor to reliably deliver messages to itself, i.e. a Self.Tell() but i want to do it such that if there is a failure at any point that the actor restarts as in an error scenario. starting from the end and going backwards, my understanding is:
the issue i have with Self.Tell() is that for number 3, any error in the dispatch process ends up getting swallowed (purposefully), since .Tell() in reality is just "please try to send this, if you can". but in theory when sending a message to yourself you should be able to close the loop instead of having the possiblity of a message being lost to the ether, however unlikely that is. so i'm thinking about doing my own direct dispatch, something like this
is this totally crazy? or is there a better way? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
I think your operating on a misconception here. Ill go over your remarks point by point and then end with some advice. 1: It depends on the supervision strategy being applied, but the default supervision strategy is to restart. See here for some specifics. Your talking about errors in the dispatch process. If by that you mean the part of a message being in the mailbox, and the actor taking it from the mailbox, there is no way this can fail. Not unless we have a serious bug in the framework that is. So that is not something you need to concern yourself with. So in short the snippet in your question is not needed, and does not provide any added benefits as opposed to simply doing My advice would be that if the message your sending has an considerate chance of failing (because your doing some kind of dangerous operation) and you want to be able to retry it without resetting the state of your actor, is to instead delegate this 'dangerous' work to a child actor and use the |
Beta Was this translation helpful? Give feedback.
I think your operating on a misconception here. Ill go over your remarks point by point and then end with some advice.
1: It depends on the supervision strategy being applied, but the default supervision strategy is to restart. See here for some specifics.
2: Correct. With the caveat of point 1 and also the message that causes the failure is not automatically retried.
3: Im not sure what you mean exactly by 'registering it for execution'. Conceptually the mailbox is a queue and the actor takes a message from this queue and processes it.
Your talking about errors in the dispatch process. If by that you mean the part of a message being in the mailbox, and the actor taking it from the mailbo…