usually, when persitent sharded actor is created it means that it has been initialized at first.
(通常,在创建永久分片actor时,这意味着它首先已初始化。)
I would suggest to create initialization message for new actor, so inside the actor you can easily detect has it been initialized or not. (我建议为新的actor创建初始化消息,以便在actor内部可以轻松检测到是否已初始化。)
I think akka .net doesn't have something out of box for it. (我认为akka .net并没有开箱即用的东西。)
For example, suppose your AuctionActor receives two messages:
(例如,假设您的AuctionActor收到两条消息:)
PlaceBid
GetBids
If you ask GetBids for actor with id = x, akka .net will check does it exists in cluster, and create it if not.
(如果您向GetBids询问id = x的actor,则akka .net将检查它是否存在于集群中,如果不存在则创建它。)
So, when your actor is started, you can't find out has this auction been started or not. (因此,当您的演员开始时,您无法发现这次拍卖是否已经开始。)
You can create third initialization message: (您可以创建第三条初始化消息:)
StartAuction
Then, when GetBids message comes, you can check inside actor has it been initialized or not.
(然后,当GetBids消息出现时,您可以检查actor内部是否已初始化。)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…