1

Let's say I have abstract actor with 2 states

Ready and Busy.

In Busy state I want to receive only particular type of messages e.g PauseJob, CancelJob, all other messages like StartNewJob get stashed.

Question: if I set SetReceiveTimeout() in Busy state, is it applied only to messages that I actually process in this state (PauseJob, CancelJob) or stashed messages are also considered?

Thanks in advance

Maxim Podkolzin
  • 378
  • 2
  • 10

1 Answers1

1

In short, stashed messages are also considered because the actor is still active while it's stashing the messages.

When you use SetRecieveTimeout() the RecieveTimeout message is sent when the actor hasn't received any messages for the designated amount of time.

private void Busy()
{
    SetReceiveTimeout(TimeSpan.FromSeconds(1));

    Receive<PauseJob>(msg =>
    {
        // Do something
    });

    Receive<ReceiveTimeout>(timeout =>
    {
        // I won't run until 1 second after 
        // all messages are processed or stashed
    });

    ReceiveAny(msg =>
    {
        Stash.Stash();
    });
}
Elliott
  • 2,035
  • 20
  • 23
  • Thanks, it seems like it's impossible to set receive timeout only for particular message types, will have to implement it manually – Maxim Podkolzin Dec 12 '16 at 21:22