AKKA.NET 个邮箱中的 SynchronizationLockException
SynchronizationLockException in AKKA.NET mailboxes
我在我的项目中使用 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;
}
}
演员实例的创建:
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)
有解决该问题的想法吗?
谢谢
这是我们在 Akka.NET 中自定义邮箱代码设计中的一个错误。它已在补丁 v1.3.8 中修复。您可以在此处关注错误修复线程:https://github.com/akkadotnet/akka.net/issues/3459
我在我的项目中使用 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;
}
}
演员实例的创建:
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)
有解决该问题的想法吗?
谢谢
这是我们在 Akka.NET 中自定义邮箱代码设计中的一个错误。它已在补丁 v1.3.8 中修复。您可以在此处关注错误修复线程:https://github.com/akkadotnet/akka.net/issues/3459