I have been using Spring.NET and NHibernate for several years, and I am very pleased. However, I always played with multi-threaded, reactive extensions and, ultimately, with a parallel task library, which is an excellent foundation. Unfortunately, all kinds of multithreaded approaches fail because of an NHiberntate session that is not thread safe.
I ask you how I can use parallel programming and still use NHibernate.
For example: I have a class CustomerRegistrationService , the Register method performs several tasks:
ICustumer customer = this.CreateCustomerAndAdresses(params); this.CreateMembership(customer); this.CreateGeoLookups(customer.Address); this.SendWelcomeMail(customer);
The last two methods are ideal candidates for parallel work, CreateGeoLookups calls some web services to determine the geographical location of the client’s address and creates some new objects, as well as updates the client itself. SendWelcomMail does what it says.
Since CreateGeoLookups uses NHibernate (although through repository objects, therefore NHibernate is hidden covertly through Interfaces / Dependency Inection), it will not work with Task.Factory.StarNew (...) or other Threading mechanisms.
My question is not to solve this very problem that I described, but I would like to hear from you about NHibenrate, Spring.NET and parallel approaches.
Thank you very much max
nhibernate task-parallel-library
Max
source share