【发布时间】:2018-06-12 01:27:25
【问题描述】:
我在我的项目中使用 AKKA.NET。有必要使用邮箱为参与者的消息设置优先级。根据文章https://getakka.net/articles/actors/mailboxes.html我创建了邮箱:
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;
}
}
创建actor实例:
ActorSystem.ActorOf(
Props.Create(() => new MyActor()).WithMailbox("myactor-mailbox"), "MyActor");
之后我将设置添加到 App.config:
<!-- language: lang-xml -->
<akka>
<hocon>
<![CDATA[
akka
{...}
myactor-mailbox
{
mailbox-type="MyActorMailBox, MyNamespace"
}
]]>
</hocon>
</akka>
我有 System.Threading.SynchronizationLockException:从未同步的代码块调用了对象同步方法。我猜它默认与邮箱中的未同步消息队列连接。 Callstack 没有关于消息类型的详细信息:
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)
有解决这个问题的想法吗?
谢谢
【问题讨论】:
-
看起来这可能是一个错误 - 将进行调查。我在这里打开并发布:github.com/akkadotnet/akka.net/issues/3459
-
如果您不介意用您正在使用的 Akka.NET 版本评论该 Github 线程,我将不胜感激!
-
感谢您的调查:)