Hello dear developers!
I use AKKA.NET in my project. There is a need to use mailboxes to set priorities for messages. According to the article https://getakka.net/articles/actors/mailboxes.html, I created a mailbox:
public class MyActorMailBox: UnboundedPriorityMailbox { public MyActorMailBox(Settings settings, Config config) : base(settings, config) {} protected override int PriorityGenerator(object message) { if (message is MyActorMailBox.ErroredMessage) return 0; return 1; } } Creating an instance of the actor with mailbox:
ActorSystem.ActorOf( Props.Create(() => new MyActor()).WithMailbox("myactor-mailbox"), "MyActor"); After that, I added the setting in App.config
<!-- language: lang-xml --> <akka> <hocon> <![CDATA[ akka {...} myactor-mailbox { mailbox-type="MyActorMailBox, MyAssembly" } ]]> </hocon> </akka> I get System.Threading.SynchronizationLockException: Object synchronization method. I guess this is due to the unsynchronized message queue in the default mailbox. The following call stack does not contain information about the type of message:
Swallowing exception during message send System.Threading.SynchronizationLockException: Object synchronization method was called from an unsynchronized block of code. at Akka.Dispatch.MessageQueues.BlockingMessageQueue.Enqueue(IActorRef receiver, Envelope envelope) at Akka.Dispatch.MessageDispatcher.Dispatch(ActorCell cell, Envelope envelope) at Akka.Actor.ActorCell.SendMessage(Envelope message) Does anyone have any ideas?
thank