Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
577 views
in Technique[技术] by (71.8m points)

akka.net - 是否有任何选择可以知道分片实体是通过恢复重新启动的(remember-entity = true)(Is there any option to know the sharded entity is re-started by recovery(remember-entity=true))

I have enabled the Cluster Sharding with remember-entities = true.

(我已使用Remember-entities = true启用了群集分片。)

So when I restart my application entities are getting recovered, but I want to know this entity is recovered or it is newly created, any way to get this?

(因此,当我重新启动时,我的应用程序实体正在恢复,但是我想知道该实体已恢复或是新创建的,有什么办法可以实现?)

  ask by abdul translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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内部是否已初始化。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...