Quartz.net - "Job's key cannot be null"
I'm trying to schedule a job on a remote scheduler using the following code:
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);
When I execute the code I get the following exception is thrown:
Quartz.SchedulerException was unhandled Message=Job's key cannot be null Source=mscorlib StackTrace: Server stack trace: Exception rethrown at [0]: at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) at Quartz.Simpl.IRemotableQuartzScheduler.ScheduleJob(IJobDetail jobDetail, ITrigger trigger) at Quartz.Impl.RemoteScheduler.ScheduleJob(IJobDetail jobDetail, ITrigger trigger) in D:\Data\ben\Projects\Utils\lahma-quartznet-b8cfbde\lahma-quartznet-b8cfbde\src\Quartz\Impl\RemoteScheduler.cs:line 424 at QuartzDemo.Program.Main(String[] args) in D:\Data\ben\Projects\demos\QuartzDemo\QuartzDemo\Program.cs:line 54 at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart() InnerException:
Everything works fine when using a local scheduler. Th开发者_开发知识库e Quartz server is running as a service and listening on tcp port 555.
This is using the latest quartz.net code from github.
This was indeed a bug but it has been fixed. Do a new pull and you'll be good to go.
There are comments on the Quartz mailing list about issues with the database access in the 2.0 release.
From the syntax, it appears that you are using the 2.0 code base. It's not even released as beta yet. I hope this isn't a production system you're putting together.
精彩评论