Subscribing to ALL ActorEvents

岁酱吖の 提交于 2019-12-11 16:54:29

问题


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.

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).

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?

Thanks for your time and suggestions!


回答1:


  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.


来源:https://stackoverflow.com/questions/46953525/subscribing-to-all-actorevents

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!