public void TestMethod1()
        {
            var quartzBuilder = new StdSchedulerFactory();
            quartzBuilder.Initialize();

            var bus = ServiceBusFactory.New(sbi =>
            {
                sbi.UseMsmq();
                sbi.UseMulticastSubscriptionClient();
                sbi.ReceiveFrom("msmq://localhost/clustertest-1");
                sbi.UseClusterService(cc =>
                {
                    cc.SetEndpointIndex(1);
                    cc.SetElectionPeriod(TimeSpan.FromSeconds(5));
                    cc.UseScheduler(quartzBuilder.GetScheduler);
                });
                sbi.EnableMessageTracing();
                sbi.UseNLog(_logFactory);
            });

            var evt = new ManualResetEventSlim(false);
            bus.SubscribeHandler<TimeoutExpired>(m =>
            {
                evt.Set();
            });

            Thread.Sleep(5000);

            bus.Publish(new ScheduleTimeout(Guid.Empty, TimeSpan.FromSeconds(10)));

            Assert.IsTrue(evt.Wait(TimeSpan.FromSeconds(30)), "Didn't get a timeout expired message");
        }
        public void Init()
        {
            Configure.Instance.Configurer.ConfigureComponent<IScheduler>(() =>
            {
                var factory = new StdSchedulerFactory();
                factory.Initialize();

                var scheduler = factory.GetScheduler();
                return scheduler;
            }, DependencyLifecycle.SingleInstance);
        }
        public void TestFactoryShouldOverrideConfigurationWithSysProperties()
        {
            NameValueCollection properties = new NameValueCollection();
            var factory = new StdSchedulerFactory();
            factory.Initialize();
            var scheduler = factory.GetScheduler();
            Assert.AreEqual("DefaultQuartzScheduler", scheduler.SchedulerName);

            Environment.SetEnvironmentVariable("quartz.scheduler.instanceName", "fromSystemProperties");
            factory = new StdSchedulerFactory();
            scheduler = factory.GetScheduler();
            Assert.AreEqual("fromSystemProperties", scheduler.SchedulerName);
        }
        public void Init()
        {
            var configurer = Configure.Instance.Configurer;
            configurer.ConfigureComponent<IJobFactory>(() => new QuartzJobFactory(Configure.Instance.Builder),DependencyLifecycle.InstancePerUnitOfWork);
            configurer.ConfigureComponent<IScheduler>(() =>
            {
                var factoryx = new StdSchedulerFactory();
                factoryx.Initialize();

                var scheduler = factoryx.GetScheduler();
                scheduler.JobFactory = Configure.Instance.Builder.Build<IJobFactory>();
                return scheduler;
            }, DependencyLifecycle.SingleInstance);
            configurer.ConfigureComponent<DoSomethingJob>(DependencyLifecycle.InstancePerUnitOfWork);
        }
        public QuartzRegistry(IContainer container)
        {
            For<IJobFactory>().Use(() => new QuartzJobFactory(container));
            For<IScheduler>().Singleton().Use(() =>
            {
                var stdSchedulerFactory = new StdSchedulerFactory();
                stdSchedulerFactory.Initialize();

                var scheduler = stdSchedulerFactory.GetScheduler();

                scheduler.JobFactory = container.GetInstance<IJobFactory>();

                return scheduler;
            });
        }
        public async Task TestFactoryShouldOverrideConfigurationWithSysProperties()
        {
            NameValueCollection properties = new NameValueCollection();
            properties["quartz.serializer.type"] = TestConstants.DefaultSerializerType;
            var factory = new StdSchedulerFactory(properties);

            factory.Initialize();
            var scheduler = await factory.GetScheduler();
            Assert.AreEqual("QuartzScheduler", scheduler.SchedulerName);

            Environment.SetEnvironmentVariable("quartz.scheduler.instanceName", "fromSystemProperties");
            // Make sure to pass the serializer type as an env var instead of in a NameValueCollection (as in the previous test)
            // since passing an explicit NameValueCollection causes the scheduler factory to not check environment variables
            Environment.SetEnvironmentVariable("quartz.serializer.type", TestConstants.DefaultSerializerType);
            factory = new StdSchedulerFactory();
            scheduler = await factory.GetScheduler();
            Assert.AreEqual("fromSystemProperties", scheduler.SchedulerName);
        }
        /// <summary>
        /// Gets the scheduler factory.
        /// </summary>
        /// <returns>The ISchedulerFactory.</returns>
        private static ISchedulerFactory GetSchedulerFactory()
        {
            var result = new StdSchedulerFactory();

            var props = ConfigurationManager.GetSection(QuartzConfigurationSectionName);

            if (props != null)
            {
                // Initialize factory with settings from config file.
                result.Initialize();
            }
            else
            {
                result.Initialize(GetDefaultProperties());
            }

            return result;
        }