【发布时间】:2011-07-21 10:59:33
【问题描述】:
我正在尝试使用以下代码在远程调度程序上安排作业:
NameValueCollection properties = new NameValueCollection();
properties["quartz.scheduler.instanceName"] = "RemoteClient";
// set thread pool info
properties["quartz.threadPool.type"] = "Quartz.Simpl.SimpleThreadPool, Quartz";
properties["quartz.threadPool.threadCount"] = "5";
properties["quartz.threadPool.threadPriority"] = "Normal";
// set remoting expoter
properties["quartz.scheduler.proxy"] = "true";
properties["quartz.scheduler.proxy.address"] = "tcp://127.0.0.1:555/QuartzScheduler";
// First we must get a reference to a scheduler
ISchedulerFactory sf = new StdSchedulerFactory(properties);
IScheduler sched = sf.GetScheduler();
// define the job and ask it to run
IJobDetail job = JobBuilder.NewJob<TestJob>()
.WithIdentity("remotelyAddedJob", "test")
.Build();
ITrigger trigger = TriggerBuilder.Create()
.WithIdentity("remotelyAddedTrigger", "test")
.ForJob(job)
.WithSchedule(CalendarIntervalScheduleBuilder.Create().WithIntervalInMinutes(1))
.Build();
// schedule the job
sched.ScheduleJob(job, trigger);
当我执行代码时,会抛出以下异常:
Quartz.SchedulerException 未处理 Message=Job 的 key 不能为空 源=mscorlib 堆栈跟踪: 服务器堆栈跟踪: 在 [0] 处重新抛出异常: 在 System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg,IMessage retMsg) 在 System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData,Int32 类型) 在 Quartz.Simpl.IRemotableQuartzScheduler.ScheduleJob(IJobDetail jobDetail, ITrigger 触发器) 在 D:\Data\ben\Projects\Utils\lahma-quartznet-b8cfbde\lahma-quartznet-b8cfbde\src\Quartz\Impl\RemoteScheduler.cs:line 中的 Quartz.Impl.RemoteScheduler.ScheduleJob(IJobDetail jobDetail, ITrigger trigger) 424 在 D:\Data\ben\Projects\demos\QuartzDemo\QuartzDemo\Program.cs:line 54 中的 QuartzDemo.Program.Main(String[] args) 在 System.AppDomain._nExecuteAssembly(RuntimeAssembly 程序集,字符串 [] 参数) 在 System.AppDomain.ExecuteAssembly(字符串 assemblyFile,证据 assemblySecurity,String [] args) 在 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() 在 System.Threading.ThreadHelper.ThreadStart_Context(对象状态) 在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext,ContextCallback 回调,对象状态,布尔 ignoreSyncCtx) 在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext,ContextCallback 回调,对象状态) 在 System.Threading.ThreadHelper.ThreadStart() 内部异常:
使用本地调度程序时一切正常。 Quartz 服务器作为服务运行并侦听 tcp 端口 555。
【问题讨论】:
标签: quartz.net