简体   繁体   English

从函数中调用Akka.Net Actor并取回确认

[英]Calling Akka.Net Actor from function and get back Acknowledgement

  1. I have an actor system with a supervisor actor implemented in the domain that is being called from outside the domain 我有一个演员系统,该管理员系统在从域外部调用的域中实现了主管演员

  2. The function invoking the supervisor actor has to wait till the response is received from supervisor in order to take the next step 调用主管角色的功能必须等到收到主管的响应后才能进行下一步

  3. Using Tell this won't be possible. 使用Tell不可能。 Using Ask, how can the supervisor actor send the message back to the calling function? 使用Ask,主管角色如何将消息发送回呼叫功能?

I have used "Ask" but since there is no actor invoking the supervisor actor, nothing is returned 我使用了“询问”,但是由于没有演员调用主管演员,因此不会返回任何内容

var result = await supervisorActor.Ask(msg);

Inside the supervisor actor to return back ack (this is not working) 在主管演员内部以返回ack(这不起作用)

private Unit Handle(Unit msg)
        => msg;

According to https://getakka.net/articles/actors/inbox.html , you should be able to use the Inbox class to interact with actors from outside the actor system. 根据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
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM