SMour
SMour

Reputation: 31

Akka.Net Async await behavior in Untyped Actor

I m using Akka.Net 1.4.1 in Windows 10 environment.

I m using async await tasks within Untyped actor and so far have not run into any issues. As expected, only the current message is processed until await for a task is completed within the OnReceive method. No parallel messaging processing for the same actor begins until one message is completely handled. However, I could not find this as a documented behavior. Most of the posts talk about using ReceiveAsync to have this behavior.

Can anyone confirm the behavior of using Async/Await inside OnReceive method of Untyped Actors in post Akka.Net 1.4.1 version?

Upvotes: 3

Views: 684

Answers (1)

Peter Csala
Peter Csala

Reputation: 22679

According to my understanding the OnReceive is not designed for async processing.

If you look at the signature of the method itself:

void OnReceive(object message)

then it returns with a void rather than with a Task.

On the other hand ReceiveAsync does receive and async handler:

void ReceiveAsync<T>(Func<T, IActorContext, Task> handler, Predicate<T> shouldHandle = null);

For further information please check this article.

Upvotes: 3

Related Questions