我一直在使用Spring.NET和NHibernate一些年,我非常满意。不过,我一直在玩多线程,Reactive Extensions和最终的Task Parallel Library,这是一个很棒的框架。不幸的是,由于NHiberntate的会话不是线程安全的,所以所有类型的多线程方法都失败了。C#任务并行库和NHibernate/Spring.NET
我在问你,我如何从并行编程中受益并仍在使用NHibernate。
例如:我有一个CustomerRegistrationService
类方法Register
执行多个任务:
ICustumer customer = this.CreateCustomerAndAdresses(params);
this.CreateMembership(customer);
this.CreateGeoLookups(customer.Address);
this.SendWelcomeMail(customer);
最后两个方法将是理想的人选运行并行,CreateGeoLookups
调用一些Web服务,以确定客户的地缘位置解决并创建一些新的实体,并更新客户本身。 SendWelcomMail
做它说的。
由于CreateGeoLookups
确实使用了NHibernate(尽管通过版本库对象使得NHibernate通过Interfaces/Dependency Inection非常隐藏),但它不能与Task.Factory.StarNew(...)或其他线程机制一起使用。
我的问题不是解决我所描述的这个问题,但我想听取您关于NHibenrate,Spring.NET和并行方法的信息。
非常感谢您 最大
你真的应该编辑你的主要问题与这个问题。这些中的任何一个都可以作为答案吗? – paqogomez 2013-09-05 03:21:59