Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 501
SMour Avatar asked Oct 14 '25 06:10

SMour


1 Answers

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.

like image 93
Peter Csala Avatar answered Oct 16 '25 21:10

Peter Csala