FlushMode: Auto ActiveEntityMode: Poco CacheMode:Put | Get
greetings Daniel On Sat, Sep 11, 2010 at 11:36 AM, Oskar Berggren <[email protected]>wrote: > What's your flush mode for the session? > > /Oskar > > > 2010/9/11 Daniel Hölbling <[email protected]>: > > This is a simplified example, from my understanding the call to > > session.Update is not necessary I know that. > > The whole thing is built with NServiceBus and there is a distributed > > transaction going on around the message handler. I also insertet that > local > > transaction to make sure it's not the distributed transaction that's > causing > > the problem. > > I checked with NHProf that all transactions get committed, and verified > > there are no errors thrown by the code. There is also no batch processing > > since I can replicate the problem with only one Message coming in on the > > Bus. > > That's exactly what NSB does by default: > > when a message is received begin the transaction. > > when a message is completed without error commit. > > when a message is completed with error rollback. > > when a message completes dispose of the transaction. > > Also looking at NHprof I don't see unnecessary sessions being opened. One > > per Message that's the way I want it to be. Sessions are not re-used from > > message to message, they are registered within Windsor as Transient. > > That's why I can't really figure out where the problem is. Everything > looks > > fine to me.. > > > > On Sat, Sep 11, 2010 at 4:05 AM, Jason Meckley <[email protected]> > > wrote: > >> > >> you don't need to call session.Update(). you should also call > >> tx.Rollback() if there is an error. > >> > >> using(var tx = session.BeginTransaction()) > >> try > >> { > >> session.Get<Product>(id); > >> product.Name = ... > >> tx.Commit(); > >> } > >> catch > >> { > >> tx.Rollback(); > >> throw; > >> } > >> > >> if you are using a messaging framework, then you can move the > >> transaction management to the command/message module (or whatever the > >> name of it is. > >> > >> when a message is received begin the transaction. > >> when a message is completed without error commit. > >> when a message is completed with error rollback. > >> when a message completes dispose of the transaction. > >> > >> then you message handler code looks like this > >> > >> session.Get<Product>(id); > >> product.Name = ... > >> > >> clean, simple code. > >> > >> another thing to consider... are you processing messages is batch? if > >> so you may be opening more sessions then necessary. this is the case > >> with Rhino.ServiceBus. You can manage if a session is open or not with > >> CurrentSessionContext. > >> > >> CurrentSessionContext.Bind(factory.OpenSession()) > >> CurrentSessionContext.HasBind(factory); > >> CurrentSessionContext.Unbind(factory).Dispose(); > >> > >> var sessionfactory.GetCurrentSession(); > >> > >> > >> On Sep 10, 8:34 pm, Daniel Hölbling <[email protected]> wrote: > >> > I've just spent almost 3 hours debugging and still can't find a fault > >> > with > >> > my code. > >> > > >> > The reproduction looks like this: > >> > > >> > using (var tx = session.BeginTransaction()) > >> > { > >> > var product = session.Get<Product>(message.ProductDto.Id); > >> > product.Name = message.ProductDto.Name; > >> > product.PartNumber = message.ProductDto.PartNumber; > >> > product.Price = message.ProductDto.Price; > >> > session.Update(product); > >> > tx.Commit(); > >> > Logger.InfoFormat("Updated Product {0}", product.Id); > >> > > >> > } > >> > > >> > I change some value of the entity in the UI, this code is run (over > the > >> > wire) and the IsDirty() Method is set to False and no Update is > >> > generated. > >> > (Checked with NHProf..) > >> > I just re-checked and upon changing the value of product.PartNumber > for > >> > 8 > >> > times it didn't generate a UPDATE once. > >> > > >> > It gets significantly worse once I run this with distributed > >> > transactions > >> > from NServiceBus where I loose every second UPDATE to the database > >> > without > >> > any error or anything.. It just doesn't update the DB since it doesn't > >> > think > >> > the session is dirty. > >> > > >> > Is there anything I should be aware of? > >> > > >> > greetings Daniel > >> > >> -- > >> 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]<nhusers%[email protected]> > . > >> For more options, visit this group at > >> http://groups.google.com/group/nhusers?hl=en. > >> > > > > -- > > 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]<nhusers%[email protected]> > . > > For more options, visit this group at > > http://groups.google.com/group/nhusers?hl=en. > > > > -- > 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]<nhusers%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/nhusers?hl=en. > > -- 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.
