Akka actors have 2 "mailboxes"/"queue"

User messages
System messages (signals)

System messages are always processed over user messages.
System messages also have stronger delivery "guarantees".

Cheers,
√



On Tue, Jan 7, 2014 at 12:56 PM, Roger Alsing <[email protected]> wrote:

> Oh, that explains it.
> I thought that each message was delivered in sequence, which I'm pretty
> sure I've seen described on a few places (?)
>
> Well, I'll try to explain what I mean more in detail
>
> pseudo code:
>
> class ActorA extends UntypedActor
> {
>      ActorRef child = context.actorOf(... ActorB...);
>      public void onReceive(Object message) throws Exception {
> ..stuff..
> child.tell(message,getSender());
> }
> }
>
> class ActorB extends UntypedActor
> {
>      public void onReceive(Object message) throws Exception {
> //broken code (for whatever reason, some missing resource or something)
> throw exception
> }
> }
>
> somewhere:
>
> for(int i=0;i<1000;i++)
>     actorA.Tell("hello",ActorRef.noSender);
>
>
> If I get things right, what will happen here is that 1000 "hello" messages
> will be passed to ActorA pretty quickly.
> that is, the queue will fill up in very fast.
>
> once the first message arrives to onReceive, it will be forwarded to
> ActorB, which throws because it is broken.
> if B tries to notify A of this without priority, the message would be
> placed at the end of the ActorA mailbox.
> so there would be no way for ActorA to stop/restart ActorB before all of
> the existing messages are handled..
> (That is ofcourse assuming that throwing exceptions is expensive and that
> there is no priority to certain messages)
>
> But if it is like you say, a priority to supervision messages, then that
> explains it.
> But that makes me curious on how that is handled?
> Is the mailbox a priority queue?
>
> Why I'm asking is that since I'm playing around with my .NET port of akka,
> I got the described above behavior. and I wondered how it is solved in real
> Akka and could not find any explanation in the code.
>
>
>
>
> Den tisdagen den 7:e januari 2014 kl. 11:43:13 UTC+1 skrev drewhk:
>>
>> Hi Roger,
>>
>> I am also a bit unsure about the question, but system messages (the
>> messages used by supervision for example) are handled with "priority"
>> compared to user messages. I am not sure this answers your question though.
>>
>> -Endre
>>
>>
>> On Tue, Jan 7, 2014 at 11:06 AM, √iktor Ҡlang <[email protected]>wrote:
>>
>>> Not sure I follow, can you create a code sample in Akka that shows the
>>> perceived problem?
>>>
>>>
>>> On Tue, Jan 7, 2014 at 8:45 AM, Roger Alsing <[email protected]> wrote:
>>>
>>>> How does the supervisor deal with congestion?
>>>>
>>>> Lets say that Actor A sends all it's incoming messages to child Actor B.
>>>> And lets say we pass 1000 messages to actor A, then actor B will
>>>> eventually also get 1000 messages.
>>>> But if B for some reason throws, e.g. on each message, then actor B
>>>> will throw a 1000 times unless stopped.
>>>>
>>>> This is where the supervisor should come in and save us, but if the
>>>> overhead of throwing an exception takes longer than passing 1000 messages
>>>> to actor A.
>>>> Then actor B will not be able to notify it's parent that it has thrown
>>>> before actor A has processed all of the initial 1000 messages.
>>>> Thus, actor B will throw 1000 times because the parent is bussy
>>>> processing those initial messages.
>>>>
>>>> Is this the expected behavior in Akka?
>>>> Or is supervision done w/o passing messages back to the owner?
>>>>
>>>> I assume stopping/removing/restarting children needs to be done in the
>>>> parent actors context and therefore use messaging to notify the parent?
>>>>
>>>>
>>>>  --
>>>> >>>>>>>>>> Read the docs: http://akka.io/docs/
>>>> >>>>>>>>>> Check the FAQ: http://akka.io/faq/
>>>> >>>>>>>>>> Search the archives: https://groups.google.com/
>>>> group/akka-user
>>>> ---
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Akka User List" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to [email protected].
>>>> To post to this group, send email to [email protected].
>>>>
>>>> Visit this group at http://groups.google.com/group/akka-user.
>>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>>
>>>
>>>
>>>
>>> --
>>> Cheers,
>>> √
>>>
>>> * Viktor Klang*
>>> *Director of Engineering*
>>> Typesafe <http://www.typesafe.com/>
>>>
>>> Twitter: @viktorklang
>>>
>>> --
>>> >>>>>>>>>> Read the docs: http://akka.io/docs/
>>> >>>>>>>>>> Check the FAQ: http://akka.io/faq/
>>> >>>>>>>>>> Search the archives: https://groups.google.com/
>>> group/akka-user
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "Akka User List" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> To post to this group, send email to [email protected].
>>>
>>> Visit this group at http://groups.google.com/group/akka-user.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>
>>  --
> >>>>>>>>>> Read the docs: http://akka.io/docs/
> >>>>>>>>>> Check the FAQ: http://akka.io/faq/
> >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
> ---
> You received this message because you are subscribed to the Google Groups
> "Akka User List" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/akka-user.
> For more options, visit https://groups.google.com/groups/opt_out.
>



-- 
Cheers,
√

*Viktor Klang*
*Director of Engineering*
Typesafe <http://www.typesafe.com/>

Twitter: @viktorklang

-- 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: http://akka.io/faq/
>>>>>>>>>>      Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to