yeah, this is what I thought. your Windsor configuration is incorrect.
you will get a unique session for each component that requires a
dependency on session. if you only have 1 object (per message) which
requires the session this works by coincidence. if you have a
situation like this
class foo { public foo(isession, bar)}
class bar { public bar(isession)}
you will get 2 unique sessions. one for foo and one for bar.the scope of the session is not the scope of processing a message using NSB. instead use a current session context and resolve the session from Windsor using factory.GetCurrentSession(); I outlined the process in my first response. You also need to manage how the component is released. ISession implements IDisposable. Windsor will attempt to dispose of the session when it's released. If you scope the session to the message processing then you need to resolve the session without the dispose burden. there are 2 ways to do that. 1. use an ISubDependencyResolver implementation 2. use a factory method and replace the component model constructor contributor with one that ignores ISession components. this would prevent the dispose burden being applied to ISession. On Sep 11, 1:27 pm, Fabio Maulo <[email protected]> wrote: > But take care with your new session-management-pattern called: "new session > per each one need it and hopefully disposed by IoC container" > > On Sat, Sep 11, 2010 at 2:12 PM, Daniel Hölbling <[email protected]>wrote: > > > I think I tracked down the bug. It seems to be the cause of my mappings. > > FNH apparently created a joined-subclass mapping. Damn I should have checked > > that before. > > Now that I removed the joined subclass the UPDATE works reliably.. :( > > > Thanks for your help guys! > > > On Sat, Sep 11, 2010 at 6:51 PM, Fabio Maulo <[email protected]> wrote: > > >> In your case you hope that Windsor take the responsibility to dispose the > >> session. > > >> On Sat, Sep 11, 2010 at 1:04 PM, Daniel Hölbling > >> <[email protected]>wrote: > > >>> I just checked. This Windsor configuration is very similar to what ayende > >>> was using in his Alexandria sample. > >>> In my case Windsor is responsible for disposing of the object. > > >>> Greetings Daniel > > >>> On 11.09.2010, at 16:48, "José F. Romaniello" <[email protected]> > >>> wrote: > > >>> You can use CurrentSessionContext, inject ISessionFactory in your > >>> DAOs/REpositories/QueryObject/Whatever and use sf.GetCurrentSession() (or > >>> sf.OpenSession() when you need) > > >>> 2010/9/11 Daniel Hölbling < <[email protected]>[email protected] > > >>>> How would you change that? > > >>>> On 11.09.2010, at 15:22, Fabio Maulo < <[email protected]> > >>>> [email protected]> wrote: > > >>>> mmmmmm > > >>>> Component.For<ISession>().UsingFactoryMethod(sessionFactory.OpenSession) > >>>> .LifeStyle.Is(LifestyleType.Transient) > >>>> this is smell a lot > > >>>> On Sat, Sep 11, 2010 at 10:11 AM, Daniel Hölbling > >>>> <<[email protected]><[email protected]> > >>>> [email protected]> wrote: > > >>>>> This is my Windsor configuration: > > >>>>> public void Install(IWindsorContainer container, IConfigurationStore > >>>>> store) > >>>>> { > >>>>> container.Kernel.AddFacility("factory", new > >>>>> FactorySupportFacility()); > >>>>> container.Kernel.AddFacility("logging", new > >>>>> LoggingFacility(LoggerImplementation.Log4net, "log4net.config")); > >>>>> container.Register( > >>>>> Component.For<ISessionFactory>().Instance(sessionFactory), > > >>>>> Component.For<ISession>().UsingFactoryMethod(sessionFactory.OpenSession) > >>>>> .LifeStyle.Is(LifestyleType.Transient) > >>>>> ); > >>>>> } > > >>>>> I agree Fabio, this has to be some sort of problem in my configuration. > >>>>> By I seriously can't find anything that's wrong. I open a session at the > >>>>> beginning of a message handler, wrapped in a distributed transaction and > >>>>> when the transaction commits the changes to my entity should persist to > >>>>> the > >>>>> Database. > >>>>> They just don't and I have no reasonable explanation for it. > > >>>>> This is btw the Fluent NH code that configures NH: > > >>>>> public ISessionFactory CreateSessionFactory(bool buildSchema = false) > >>>>> { > >>>>> var persistenceConfigurer = configuration.GetDatabase(); > >>>>> var autoPersistenceModel = > >>>>> AutoMap.AssemblyOf<AggregateRoot>(new AutomappingConfig()); > > >>>>> return Fluently.Configure() > >>>>> .Database(persistenceConfigurer) > >>>>> .Mappings(m => > >>>>> { > >>>>> m.AutoMappings.Add(autoPersistenceModel); > >>>>> }) > >>>>> .ExposeConfiguration(SetEventListeners) > >>>>> .ExposeConfiguration((cfg) => { if (buildSchema) > >>>>> BuildSchema(cfg); }) > >>>>> .ExposeConfiguration(UpdateSchema) > >>>>> .BuildSessionFactory(); > >>>>> } > > >>>>> greetings Daniel > > >>>>> On Sat, Sep 11, 2010 at 2:28 PM, Fabio Maulo < > >>>>> <[email protected]><[email protected]> > >>>>> [email protected]> wrote: > > >>>>>> If you write that code in a pure-100%-NH-based-test you will see an > >>>>>> update. > > >>>>>> On Fri, Sep 10, 2010 at 9:34 PM, Daniel Hölbling > >>>>>> <<[email protected]><[email protected]> > >>>>>> [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]><[email protected]> > >>>>>>> [email protected]. > >>>>>>> To unsubscribe from this group, send email to > >>>>>>> <nhusers%[email protected]><[email protected]> > >>>>>>> [email protected]. > >>>>>>> For more options, visit this group at > >>>>>>> <http://groups.google.com/group/nhusers?hl=en><http://groups.google.com/group/nhusers?hl=en> > >>>>>>>http://groups.google.com/group/nhusers?hl=en. > > >>>>>> -- > >>>>>> Fabio Maulo > > >>>>>> -- > >>>>>> You received this message because you are subscribed to the Google > >>>>>> Groups "nhusers" group. > >>>>>> To post to this group, send email to > >>>>>> <[email protected]><[email protected]> > >>>>>> [email protected]. > >>>>>> To unsubscribe from this group, send email to > >>>>>> <nhusers%[email protected]><[email protected]> > >>>>>> [email protected]. > >>>>>> For more options, visit this group at > >>>>>> <http://groups.google.com/group/nhusers?hl=en><http://groups.google.com/group/nhusers?hl=en> > >>>>>>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]><[email protected]> > >>>>> [email protected]. > >>>>> To unsubscribe from this group, send email to > >>>>> <nhusers%[email protected]><[email protected]> > >>>>> [email protected]. > >>>>> For more options, visit this group at > >>>>> <http://groups.google.com/group/nhusers?hl=en><http://groups.google.com/group/nhusers?hl=en> > >>>>>http://groups.google.com/group/nhusers?hl=en. > > >>>> -- > >>>> Fabio Maulo > > >>>> -- > >>>> You received this message because you are subscribed to the Google > >>>> Groups "nhusers" group. > >>>> To post to this group, send email to <[email protected]> > >>>> [email protected]. > >>>> To unsubscribe from this group, send email to > >>>> <[email protected]> > >>>> [email protected]. > >>>> For more options, visit this group at > >>>> <http://groups.google.com/group/nhusers?hl=en> > >>>>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]> > >>>> [email protected]. > >>>> To unsubscribe from this group, send email to > >>>> <nhusers%[email protected]> > >>>> [email protected]. > >>>> For more options, visit this group at > >>>> <http://groups.google.com/group/nhusers?hl=en> > >>>>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. > > >>> -- > >>> 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. > > >> -- > >> Fabio Maulo > > >> -- > >> 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 > > ... > > read more » -- 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.
