本文介绍了订阅所有ActorEvent的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的WebApi中,我想为我的ActorId的全部订阅ActorEvent.订阅单个ActorId 很容易,并且有效.但是,我想知道是否可以同时订阅所有内容以及将来的所有内容,而我可能会在文档中错过它.

In my WebApi I want to subscribe to the ActorEvents for all of my ActorIds. Subscribing to a single ActorId is easy, and works. However, I'm wondering if there is a way to subscribe everything all and future ones at once, that I might've missed in the documentation.

当前,我正在遍历WebApi启动和订阅中的所有ActorId.然后,我订阅新的ID,然后取消订阅已删除的ID.但是,这有点麻烦,并且由于它是在启动过程中的,如果任何参与者都没有启动并运行(部署时发生),它将抛出错误并停止api进程.

Currently, I'm iterating through all my ActorIds on WebApi startup and subscribing. I then subscribe to new Ids, and unsubscribe from deleted ones. However, this is somewhat cumbersome, and since it is during startup, will throw errors and stop the api process if any of the actors aren't up and running (happens on deployment).

还要考虑的是,可以在多个IActor中使用相同的ActorId.例如UserActor(Bob),Wishlist(Bob)等.

Also for consideration, is that the same ActorId may be used in multiple IActors. For example UserActor(Bob), Wishlist(Bob), etc.

关于如何最好地订阅任何内容的任何建议?

Any suggestions on how best to subscribe to anything?

感谢您的时间和建议!

推荐答案

  1. 您不能订阅将来的Actor事件,因为它们尚不存在.作为一种解决方法,您可以使Actor在创建时将自己注册到中央集线器.并使用它代替 ActorEvents .一种方法是使用类似 pub/sub 的东西.
  2. ActorId 只是标识一个Actor,它用于确定存储在其上的 ActorService 分区.它不包含Actor类型信息,因此可以安全地在不同Actor类型之间重复使用.
  1. You can't subscribe to future Actor events, because they don't exist yet. As a workaround, you can make the Actors register themselves to a central hub, as they are created. And use that instead of ActorEvents. One way to do this is by using something like pub/sub.
  2. An ActorId simply identifies an Actor and it is used to determine the ActorService partition it is stored on. It does not hold Actor type info, sou it's safe to re-use it across different Actor types.

这篇关于订阅所有ActorEvent的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-22 21:51