5

Reading the documentation for Topshelf integrations here: https://github.com/dtinteractive/Topshelf.Integrations

And it seems like it should be as simple as scheduling multiple quartz jobs within the HostFactory but it looks like the second scheduled job is the only one that's running.

I'm not really sure how to proceed from here. But I need to schedule two jobs that run on different schedules. The first is supposed to be run daily while the second gets run hourly.

static void Main(string[] args)
    {
        HostFactory.Run(x =>                                 
        {
            x.ScheduleQuartzJobAsService(q =>
                q.WithJob(() => JobBuilder.Create<TmsIdImportTask>().Build())
                    .AddTrigger(() =>
                        TriggerBuilder.Create()
                            .WithSimpleSchedule(builder => builder
                                .WithIntervalInMinutes(Int32.Parse(ConfigurationManager.AppSettings["ScheduleImportFrequencyInMinutes"]))
                                .RepeatForever()).Build())
            );

            x.ScheduleQuartzJobAsService(q =>
                q.WithJob(() => JobBuilder.Create<ImportTmsXMLTask>().Build())
                    .AddTrigger(() => TriggerBuilder.Create().WithSimpleSchedule(builder =>
                        builder.WithIntervalInMinutes(Int32.Parse(ConfigurationManager.AppSettings["TMSImportFrequencyInMinutes"]))
                        .RepeatForever()).Build())
                        );


            x.RunAsLocalSystem();

            var description = ConfigurationManager.AppSettings["ServiceDescription"];
            x.SetDescription(description);

            var displayName = ConfigurationManager.AppSettings["ServiceDisplayName"];
            x.SetDisplayName(displayName);

            var serviceName = ConfigurationManager.AppSettings["ServiceName"];
            x.SetServiceName(serviceName);                       
        });       
    }
4

2 回答 2

8

我相信您遇到问题的原因是因为您正在使用

x.ScheduleQuartzJobAsService

代替

x.ScheduleQuartzJob

我只是第一次使用 Quartz,但我有 20 个不同的时间表都在同一主机内运行

于 2014-01-28T20:15:34.493 回答
4

在 Topshelf-Quartz 集成上创建第二个服务或平底船,并拥有一个初始化两个 Quartz 实例并将其关闭的服务。

按照设计,Topshelf 只会托管一个 [服务] 进程。如果 Topshelf 托管多个进程,您将无法管理或监控任何有用的内容。它最终成为一种不可持续的模式。

于 2014-01-22T23:42:12.703 回答