Question

I have a web application based on the sharp-architecture framework. It actually use NHibernate for the dal, and i've added a service layer between the (VIEW-CONTROLLER) and the DAL.

I actually need to implement a scheduler to run my jobs frequently. I will use Quartz.net to do that task. Actually i'm facing a problem. Because I will have lot's of jobs that will run at different schedule, like every 30 sec, every days, every weeks.

I want to know if there is a way to run NHibernate with service injection inside Quartz, and if it will support job concurrence, I mean if two jobs runs simultaniously, if there will be no problems with NHibernate. I know there is some issue with NHibernate and multithreading.

I found an implementation of Quartz.Net for Spring (http://www.zorched.net/2009/03/07/using-quartznet-springnet-and-nhibernate-to-run-scheduled-tasks-in-aspnet/) and an implementation for Castle-Windsor (http://bugsquash.blogspot.com/2009/03/windsor-facility-for-quartznet.html).

The problem is, I think this examples don't take care of the case that jobs can be ran simultaniously, that's an Nhibernate problem. And i want to use CommonServiceLocator to be more high level and not limit myself to one IoC framework.

What can be the best approach to solve this problem ?

Thanks for your help

Was it helpful?

Solution

Use the NHibernate facility, then inject ISessionManager in your IJobs. That should give you one ISession per thread and you should have no problems.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top