【发布时间】:2013-09-24 13:46:34
【问题描述】:
我正在使用作为服务安装的 Quartz.net 2.2。作业存储在 ms sql express 中,使用 AdoJobStore。这些作业是从 asp.net 4 网站管理的。 一切正常,正如预期的那样:服务正在运行,作业已正确存储和触发。 我面临的问题是,每天早上 7 点之后(这是应用程序池回收的时间)并且我访问该站点时,都会出现此错误:
对象“/QuartzScheduler”已断开连接或在服务器上不存在。
[RemotingException: 对象“/QuartzScheduler”已断开连接或在服务器上不存在。] System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) +9443827 System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 类型) +345 Quartz.Simpl.IRemotableQuartzScheduler.get_SchedulerName() +0 Quartz.Impl.RemoteScheduler.b__6(IRemotableQuartzScheduler x) +8 Quartz.Impl.RemoteScheduler.CallInGuard(Func`2 func) +61
[SchedulerException: 与远程调度程序通信时出错。] Quartz.Impl.RemoteScheduler.CallInGuard(Func`2 func) +100 Quartz.Impl.RemoteScheduler.get_SchedulerName() +92 Quartz.Impl.SchedulerRepository.Bind(IScheduler sched) +65 Quartz.Impl.StdSchedulerFactory.Instantiate() +1815 Quartz.Impl.StdSchedulerFactory.GetScheduler() +102 ASP.global_asax.Application_Start(Object sender, EventArgs e) +241
[HttpException (0x80004005): 与远程调度程序通信时出错。] System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext 上下文,HttpApplication 应用程序)+9189101 System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext,HttpContext 上下文,MethodInfo[] 处理程序)+131 System.Web.HttpApplication.InitSpecial(HttpApplicationState 状态,MethodInfo[] 处理程序,IntPtr appContext,HttpContext 上下文)+194 System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +339 System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +253
[HttpException (0x80004005): 与远程调度程序通信时出错。] System.Web.HttpRuntime.FirstRequestInit(HttpContext 上下文) +9104200 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext 上下文)+97 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +256
在此之后,如果我去服务器,我停止/启动 Quartz.net 服务,那么站点将正确启动。
每次我通过 FTP 上传修改的 web.config 或修改的另一个文件时都会发生同样的事情,这会导致网站重新启动。在这里我得到了同样的错误,我可以绕过停止和重新启动 Quartz.net 服务。
这是网站的 global.asax:
public static ISchedulerFactory SchedulerFactory;
public static IScheduler Scheduler;
void Application_Start(object sender, EventArgs e)
{
NameValueCollection p = new NameValueCollection();
p["quartz.scheduler.instanceName"] = "MyScheduler";
p["quartz.scheduler.proxy"] = "true";
p["quartz.threadPool.threadCount"] = "0";
p["quartz.scheduler.proxy.address"] = "tcp://localhost:555/QuartzScheduler";
SchedulerFactory = new StdSchedulerFactory(p);
Scheduler = SchedulerFactory.GetScheduler(); // <-- The exception seems to occur here
if (!Scheduler.IsStarted)
Scheduler.Start();
}
void Application_End(object sender, EventArgs e)
{
Scheduler.Shutdown(true);
}
【问题讨论】:
标签: asp.net quartz-scheduler quartz.net