what does nhibernate save to the database? what were your events to to the reporting side?
are they the same? can you prove it? what if they aren't? On Wed, Mar 24, 2010 at 11:35 PM, Jason Meckley <[email protected]> wrote: > I have one way commands coming from the client. the commands are > consumed. consuming includes 1. Nh getting entity(s) and updating 2. > sending events in the domain stating "this happened". it seems natural > to me, what am I missing? > > On Mar 24, 4:10 pm, Greg Young <[email protected]> wrote: >> This has nothing to do with eventual consistency... >> >> This has to do with the fact that you have 2 models and 2 ways of >> detecting changes. How do you insure they find the same changes? >> >> Greg >> >> >> >> On Wed, Mar 24, 2010 at 10:09 PM, Jason Meckley <[email protected]> >> wrote: >> > the possibility does exist for the pvm and domain to be out of sync. I >> > understood this as eventual consistency. Are you talking about >> > permanently loosing consistency. Like entire handlers not succeeding? >> >> > Lets assume that events will succeed. in my current architecture the >> > domain and pvm are updated within the same transaction. Is there a way >> > to retrieve the tasks id? >> >> > On Mar 24, 3:22 pm, Greg Young <[email protected]> wrote: >> >> How do you prove that the events that you publish to the reporting >> >> model (and every other model) from your domain match what nhibernate >> >> (or any other ORM) believes your changes to be? It is a difficult >> >> problem and the models,your database model and your eventing model, >> >> will diverge over time resulting in corrupt data and unsuspected >> >> behaviors... >> >> >> Example: >> >> >> I have a use case that changes a phone number. The phone number event >> >> is generated properly but somehow in the process of doing this I also >> >> ended up changing the address. No address event is generated. My user >> >> gets an error message saying they must be in CT to do some operation >> >> and that is what they see on the screen because they are viewing from >> >> the reporting model (which never received the change). >> >> >> Another example: >> >> >> I have a use case that changes a phone number and an address. I >> >> generate two events that represent each change but forget to update >> >> the state of my object so nhibernate only sees one change. As such my >> >> reporting model has both but my normal database has only one. >> >> >> In order to test for this type of thing you have to integration test >> >> your database not just that your changes that you expect actually >> >> happen you also have to test that no change that you did not expect to >> >> happen happenned. The answer is to not use two models where possible. >> >> >> Cheers, >> >> >> Greg >> >> >> On Wed, Mar 24, 2010 at 9:12 PM, Jason Meckley <[email protected]> >> >> wrote: >> >> > Greg, thank you the *concise* response :) care to elaborate? I can see >> >> > how my design may fail, but how can a tool fail? >> >> > If I choose Guid as my id, my approach might work. If I choose >> >> > Identity (or some other db POID) this will definitely work. I'm hoping >> >> > there's is 3rd option which I'm not aware of. >> >> >> > On Mar 24, 2:57 pm, Greg Young <[email protected]> wrote: >> >> >> If you are spiking a greenfield app with CQRS using nhibernate or any >> >> >> orm will lead to a complete and utter failure. >> >> >> >> On Wed, Mar 24, 2010 at 8:48 PM, Jason Meckley >> >> >> <[email protected]> wrote: >> >> >> > I am spiking an example of CQRS as described by Udi. I am using rhino >> >> >> > service bus to process commands and then fire events in the domain. >> >> >> > I'm using a 'To Do List' for the spike >> >> >> >> > public void Consume(NewQuickTask message) >> >> >> > { >> >> >> > var task= >> >> >> > session.Get<User>(message.UserId).AddTask(message.Title); >> >> >> > domainEvents.Raise(new QuickTaskAdded{Task= task}); >> >> >> > } >> >> >> >> > where domainEvents.Raise() will resolve all the Handles<T> from the >> >> >> > container and execute against each one. for example >> >> >> > class InsertNewQuickTaskIntoPersisentViewModel: >> >> >> > Handles<QuickTaskAdded> >> >> >> > { >> >> >> > public void Handle(QuickTaskAdded arg) >> >> >> > { >> >> >> > var pvm = mapper.Map<Task, ListOfItemsToDo>(arg.Task); >> >> >> > session.Save(pvm); >> >> >> > } >> >> >> > } >> >> >> >> > ListOfItemsToDo uses the assigned POID. this way it has the same id >> >> >> > as >> >> >> > the Task in the domain. Task uses HiLo POID. I know I can call >> >> >> > session.Save(new Task()); to get the id, but I'm adding the Task to >> >> >> > the User to avoid the explicit call to session. >> >> >> >> > however I need the id from Task to insert new records into the PVM >> >> >> > (persistent view model). Is there another way to do this with HiLo? I >> >> >> > could probably use Guid.Comb, but I prefer numbers since they are >> >> >> > easier to read when logging and generating urls. I'm trying to avoid >> >> >> > database POID strategies for now. >> >> >> >> > -- >> >> >> > You received this message because you are subscribed to the Google >> >> >> > Groups "nhusers" group. >> >> >> > To post to this group, send email to [email protected]. >> >> >> > To unsubscribe from this group, send email to >> >> >> > [email protected]. >> >> >> > For more options, visit this group >> >> >> > athttp://groups.google.com/group/nhusers?hl=en. >> >> >> >> -- >> >> >> Les erreurs de grammaire et de syntaxe ont été incluses pour m'assurer >> >> >> de votre attention >> >> >> > -- >> >> > You received this message because you are subscribed to the Google >> >> > Groups "nhusers" group. >> >> > To post to this group, send email to [email protected]. >> >> > To unsubscribe from this group, send email to >> >> > [email protected]. >> >> > For more options, visit this group >> >> > athttp://groups.google.com/group/nhusers?hl=en. >> >> >> -- >> >> Les erreurs de grammaire et de syntaxe ont été incluses pour m'assurer >> >> de votre attention >> >> > -- >> > You received this message because you are subscribed to the Google Groups >> > "nhusers" group. >> > To post to this group, send email to [email protected]. >> > To unsubscribe from this group, send email to >> > [email protected]. >> > For more options, visit this group >> > athttp://groups.google.com/group/nhusers?hl=en. >> >> -- >> Les erreurs de grammaire et de syntaxe ont été incluses pour m'assurer >> de votre attention > > -- > You received this message because you are subscribed to the Google Groups > "nhusers" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/nhusers?hl=en. > > -- Les erreurs de grammaire et de syntaxe ont été incluses pour m'assurer de votre attention -- You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.
