c# - 从函数中调用 Akka.Net Actor 并返回 Acknowledgment

标签 c# .net-core akka.net

  1. 我有一个 Actor 系统,其中有一个在域中实现的 Supervisor Actor,该域是从域外部调用的

  2. 调用supervisor actor的函数必须等到收到supervisor的响应才能执行下一步

  3. 使用 Tell 这是不可能的。使用 Ask,主管 Actor 如何将消息发送回调用函数?

我使用了“Ask”,但由于没有 Actor 调用主管 Actor ,所以没有返回任何内容

var result = await supervisorActor.Ask(msg);

在supervisor actor内部返回ack(这不起作用)

private Unit Handle(Unit msg)
        => msg;

最佳答案

根据https://getakka.net/articles/actors/inbox.html ,您应该能够使用 Inbox 类与 Actor 系统外部的 Actor 进行交互。

var target = system.ActorOf(Props.Empty);
var inbox = Inbox.Create(system);

inbox.Send(target, "hello");

try
{
    inbox.Receive(TimeSpan.FromSeconds(1)).Equals("world");
}
catch (TimeoutException)
{
    // timeout
}

关于c# - 从函数中调用 Akka.Net Actor 并返回 Acknowledgment,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55836581/

相关文章:

c# - Azure Active Directory 身份验证损坏 - 没有已知的根本原因

c# - 如何在AuthorizationHandler中获取POST请求参数

c# - 如何在面向 net462 框架的 .Net Core 项目中使用 ConfigurationPropertyAttribute?

c# - 如何在 Visual Studio 2019 中使用 Xamarin Forms(UWP) 和 C# 创建 Web 应用程序

azure - Akka.NET 记录器不将日志发送到 Application Insights

AKKA.NET 和 DeathWatchNotification

c# - 如何通过c#连接到MySQL数据库?

c# - 手动编码编码的 UI 测试

c# - 如何使用 asp.net mvc webapi 发送电子邮件附件

powershell - 为什么从 PowerShell 调用 F# 代码时收到 MissingMethodException?