【问题标题】:SynchronizationLockException in AKKA.NET mailboxesAKKA.NET 邮箱中的 SynchronizationLockException
【发布时间】: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 线程,我将不胜感激!
  • 感谢您的调查:)

标签: .net akka.net


【解决方案1】:

这是我们在 Akka.NET 中自定义邮箱代码设计中的一个错误。它已在补丁 v1.3.8 中修复。您可以在此处关注错误修复线程:https://github.com/akkadotnet/akka.net/issues/3459

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-18
    • 1970-01-01
    • 2012-04-05
    • 2013-08-15
    • 2011-11-24
    相关资源
    最近更新 更多