thangchung / magazine-website-akka

The experiment on the akkadotnet
MIT License
23 stars 9 forks source link

Sagas implementation #7

Open thangchung opened 7 years ago

thangchung commented 7 years ago

Consider could we use the https://github.com/dotnet-state-machine/stateless to implement the state-machine for the admin approval the article submission from the editor. Maybe we need to choose the workflow lib to make it work

thangchung commented 7 years ago

Read this for more clear about state machine, workflow and sagas https://medium.com/@roman01la/confusion-about-saga-pattern-bbaac56e622#.7x70mb8q3 Another collection of articles about Sagas at https://github.com/thangchung/magazine-website-akka/wiki/Saga-research

thangchung commented 7 years ago

stateless + quartz + topshelf

We can use Quartz (https://github.com/quartznet/quartznet) to schedule the job (run forever) and inside that job, we can trigger the stateless's state machine to get it work. Not sure it works or not? Need to check https://stackoverflow.com/questions/25299662/executing-multiple-quartz-net-jobs-with-topshelf I think Topself will boot the Service to run the persistence actor, inside that actor will get events from event store to re-init the state of the Aggregate of entity, then we can instance the stateless's state machine for run in every 1 minute or more by using Quartz

akka FSM + quartz + topshelf

The best way to do here is akka state machine with Quatz

thangchung commented 7 years ago

Really nice example using stateless at https://sachabarbs.wordpress.com/2013/05/16/simple-but-nice-state-machine/

thangchung commented 7 years ago

A lot of references in case we need to learn more http://blog.jonathanoliver.com/cqrs-sagas-with-event-sourcing-part-i-of-ii/ https://abdullin.com/lokad-cqrs-retrospective/ https://msdn.microsoft.com/en-us/magazine/mt238399.aspx?f=255&MSPPError=-2147217396 https://www.slideshare.net/PieterKoornhof/event-sourcing-and-why-it-is-a-good-choice (https://github.com/SneakyPeet/EasyEventSourcing)

// in the FE https://github.com/paldepind/functional-frontend-architecture/issues/20#issuecomment-158694062 https://blog.javascripting.com/2015/08/12/reduce-your-side-effects/

thangchung commented 7 years ago

https://github.com/vrcod/akka-sample-persistent-fsm/blob/master/src/main/scala/PersistentFSMExample.scala

thangchung commented 7 years ago

The next refactor should be as

  1. Separate the process manager into another service, maybe ProcessManager service
  2. Make current CategoryService builds the actor selection that points to the ProcessManager service
  3. Then each request in CategoryService will trigger the command to the ProcessManager service
  4. ProcessManager service will take care of inter-communication with side-effect services like email, pdf... services to finish its works and persistence its state into the storage via akka's PersistenceFSM
thangchung commented 7 years ago

Good for reference at http://vasters.com/archive/Sagas.html