azure - Service Fabric actors that receive events from other actors -


i'm trying model news post contains information user posted it. believe best way send user summary information along message create news post, i'm little confused how update summary information if underlying user information changes. right have following newspostactor , useractor

public interface inewspostactor : iactor {     task setinfoandcommitasync(newspostsummary summary, usersummary postedby);      task addcommentasync(string content, usersummary, postedby); }  public interface iuseractor : iactor, iactoreventpublisher<iuseractorevents> {     task updateasync(usersummary summary); }  public interface iuseractorevents : iactorevents {     void userinfochanged(); } 

where i'm getting stuck how have inewspostactor implementation subscribe events published iuseractor. i've seen subscribeasync method in sample code @ https://github.com/azure/servicefabric-samples/blob/master/samples/actors/vs2015/voicemailboxadvanced/voicemailboxadvanced.client/program.cs#l45 appropriate use inside newspostactor implementation? keep actor alive reason?

additionally, have ability add comments news posts, should newspostactor keep subscription each iuseractor each unique user comments?

service fabric actors not yet support publish/subscribe architecture. (see azure feedback topic current status.)

as answered charisk, actor-events not way go because not have delivery guarantees.

this means, useractor has initiate request when name changes. can think of multiple options:

  • from within iuseraccount.changenameasync() can send requests directly newspostactors (assuming useraccount holds list of posts). however, introduce additional latency since client has wait until posts have been updated.

  • you can send requests asynchronously. easy way set "namechanged"-property on actor state true within changenameasync() , have timer regularly checks property. if true, sends requests newspostactors , sets property false afterwards. improvement previous version, still implies strong connection between useraccounts , newsposts.

  • a more scalable solution introduce "message router"-pattern. can read more pattern in vaughn vernon's excellent book "reactive messaging patterns actor model". way can setup own pub/sub model sending "namechanged"-message router. newspostactors can - depending on scalability needs - subscribe message either directly or through indirection (maybe newspostcoordinator). , depending on scalability needs, router can forward messages either directly or asynchronously (by storing in queue first).


Comments

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -