Hi George,

the general sequence of processing a Command is
verification (i.e. is the Command legal in the current state)
emit events
when events are persisted
apply effect of events to local state
execute side-effects

Business logic defines both steps 1 and 3, but the only problematic part are 
the side-effects: only those cannot be taken back or reversed, and usually they 
are not idempotent—charging a credit card twice will charge twice the amount. 
The decision on whether to execute side-effects during replay (or after replay, 
if also persisting the effect of having performed the side-effect) is based on 
the problem domain, it is given by whether your business needs to guarantee 
at-most-once or at-least-once; exactly-once is a pipe dream that does not exist 
in the real world.

Regards,

Roland

1 aug 2014 kl. 03:25 skrev George Wilk <[email protected]>:

> Thank you both for your replies.  This is exactly the information I was 
> looking for.  I wanted to know if business logic should be applied in the 
> command handling portion of the event processor before the event is 
> generated, or after the fact.  What was throwing me off was a statement I 
> read in akka persistence doc explaining role of the journal:
>  "Journal: A journal stores the sequence of messages sent to a persistent 
> actor."  
> 
> Since event processor does not store commands, and journal's role is to store 
> messages sent to persistent actor, this convinced me that events stored in 
> journal are simply messages derived from commands before any business logic 
> is applied.  Apparently my assumptions were incorrect.  It became clea in my 
> mind what should be happening during state restoration process when the 
> events are being replayed from journal.  Namely, state is simply updated 
> using events replayed from journal w/o running them through any business 
> rules.  Fair enough.
> 
> Cheers,
> ~g
> 
> -- 
> >>>>>>>>>> Read the docs: http://akka.io/docs/
> >>>>>>>>>> Check the FAQ: 
> >>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
> >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
> --- 
> You received this message because you are subscribed to the Google Groups 
> "Akka User List" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/akka-user.
> For more options, visit https://groups.google.com/d/optout.



Dr. Roland Kuhn
Akka Tech Lead
Typesafe – Reactive apps on the JVM.
twitter: @rolandkuhn


-- 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: 
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>>      Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to