【问题标题】:Calling Akka.Net Actor from function and get back Acknowledgement从函数调用 Akka.Net Actor 并返回确认
【发布时间】:2019-04-24 18:38:13
【问题描述】:
  1. 我有一个actor系统,在域中实现了一个主管actor,从域外调用

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

  3. 无法使用 Tell。使用 Ask,主管 Actor 如何将消息发送回调用函数?

我使用了“询问”,但由于没有调用主管演员的演员,所以没有返回任何内容

var result = await supervisorActor.Ask(msg);

在主管actor里面返回ack(这个不行)

private Unit Handle(Unit msg)
        => msg;

【问题讨论】:

  • 我想你可能想看看Inboxgetakka.net/articles/actors/inbox.html
  • 非常感谢。 “收件箱”对我有用。如上面链接中所述,“询问”没有收到多个回复。
  • @mclark1129 您应该将其发布为答案!
  • @GautamTGoudar 如果您不介意接受它,我添加了此评论作为答案!

标签: c# .net-core akka.net


【解决方案1】:

根据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
}

【讨论】:

    猜你喜欢
    • 2020-04-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-29
    相关资源
    最近更新 更多