TransferMoneyCommand
Handler -> loads correct Account AR -> executes behavior
Domain behavior decides whether or not this transfer is permitted
- NO -> throws an exception (this is just the example)
- YES -> Fires a MoneyTransferedEvent containing the account, amount and ...
Event handler picks this up, checks if it is a local (to the bank)
account or not (actually a domain service will most likely do this
checking)
- NO -> Fires a command to send this to the external bank
- YES -> Fires a command ReceiveMoneyTransfer for the receiving AR
Money gets added by the behvior resulting in a MoneyTransferReceivedEvent
Event gets published
If anything here goes wrong the whole chain is being compensated, this
happens by again a command and events ;)
-Mark
--
Mark Nijhof
m: 0047 95 00 99 37
e: mark....@cre8ivethought.com
w: www.cre8ivethought.com
"Walking on water and developing software from a specification are
easy if both are frozen."
-- Edward V Berard
-Mark
-Mark
> But on AR can of course publish multiple
> events per behavior (command call this behavior) all tho I haven't
> really seen it yet. Either eventA or eventB is more likely.
>
> -Mark
I had a brief discussion in another thread about this. in my replication scenario, i perceive a need for events to be linked in some fashion so that conflict resolution can be more readily achieved. if events appear as discrete items, understanding what needs to be resolved will be much more difficult.
--
Les erreurs de grammaire et de syntaxe ont été incluses pour m'assurer
de votre attention
I want to reconcile 2 events as they come down the stream. I don't
really care if they were written originally in the same transaction,
just that I can tie them together...
consider:
transfercreated
deposit
withdrawl
transfercompleted
where you would also be getting any error handling to occur. At no
time does one command ever affect more than 1 aggregate ...
On 31/07/2010, at 20:40, Greg Young <gregor...@gmail.com> wrote:
Buy side:
A 1000 @ 1.00
B 100 @ 1.00
C 5000 @ .99
D 400 @.99
PlaceOrderCommand
S Sell 1500 @ .99
generates
Trade A-S 1000 @ 1.00
Trade B-S 100 @ 1.00
Trade C-S 400 @ .99
Make sense?
--
Simon Harris
w: http://www.harukizaemon.com/
e: haruki...@mac.com
m: +61 417 505 611
t: @haruki_zaemon
Indeed, so I'll be more precise: atomicity over multiple writes. If a command can result in multiple events then atomicity is required for multiple writes which, considering most datastores I can think have either atomicity for a single write/update or fully-blown, ACID, transactions, effectively means a datastore supporting transactions.
In my case I'm looking at CouchDB which has only atomicity of a single write/update. That said it has sophisticated map/reduce views so, I'm considering writing a unit-of-work as a single document and then using map/reduce views to expose the underlying events.
I guess that means no, there's no assumption of multi-write atomicity however I am using a trick -- albeit an intentional, first-order concept -- of the datastore to achieve the same effect. The nice thing about this is I get my linking of related events for "free".
> Another alternative is to stream in multiple messages and then write
> the final commit message, which will contain identities of the
> messages to be considered as written.
I hadn't considered logical transactions. In my case, I think I'm still erring on the side of committing a unit of work and using views to present it as a sequence of events.
Thanks.
--
Best regards,
*Rinat Abdullin*
Technology Leader at Lokad.com <http://www.lokad.com> | Writer at
Abdullin.com <http://abdullin.com> | Contacts <http://abdullin.com/contact/>
Either way we can consider definite multi-write atomicity at the
logical level, as long as all events in a batch belong to the same
entity.
On Sunday, August 1, 2010, Simon Harris <haruki...@mac.com> wrote:
--