每个应用程序可以创建多少个调度程序?
How many schedulers can I create per application?
似乎是 StdSchedulerFactory
returns 一个单例,其名称在配置中定义:
<add key="quartz.scheduler.instanceName" value="MyQuartzScheduler" />
由于 quartz 配置部分由键值对组成,因此使用工厂实例化调度程序似乎将可用调度程序的数量限制为一个。
AFIAK,您可以在任何应用程序中创建任意数量的调度程序,但您不能为此使用默认的石英配置方法,因为它只需要一个 collection 调度程序属性(查看 StdSchedulerFactory
implementation and this 博客(如果有趣的话):
By default, In Quartz.Net, the StdSchedulerFactory is responsible for configuring the scheduler. When the Quartz.Net scheduler is started, the factory will try to automatically configure a scheduler by looking for configuration information in different places:
- the hosting application’s configuration file
- a file specified in an environment variable
- the quartz.config file
- the embedded configuration file
所以你可以做的不是使用自动调度程序配置,而是
自己创建一个单独的 collection 属性并将它们传递给调度程序创建构造函数:
public StdSchedulerFactory(NameValueCollection props);
使用代码方法:
NameValueCollection scheduler1Properties = new NameValueCollection();
properties["quartz.scheduler.instanceName"] = "SingleThreadScheduler";
properties["quartz.threadPool.type"] = "Quartz.Simpl.SimpleThreadPool, Quartz";
properties["quartz.threadPool.threadCount"] = "1";
...
var factory = new StdSchedulerFactory(scheduler1Properties);
或者您可以创建单独的石英配置并直接使用石英 PropertiesParser class 读取
/// <summary>
/// Reads the properties from file system.
/// </summary>
/// <param name="fileName">The file name to read resources from.</param>
/// <returns></returns>
public static PropertiesParser ReadFromFileResource(string fileName)
并得到 collection:
/// <summary>
/// Gets the underlying properties.
/// </summary>
/// <value>The underlying properties.</value>
public virtual NameValueCollection UnderlyingProperties
{
get { return props; }
}
// PropertiesParser
class直接用于default配置读取实现
似乎是 StdSchedulerFactory
returns 一个单例,其名称在配置中定义:
<add key="quartz.scheduler.instanceName" value="MyQuartzScheduler" />
由于 quartz 配置部分由键值对组成,因此使用工厂实例化调度程序似乎将可用调度程序的数量限制为一个。
AFIAK,您可以在任何应用程序中创建任意数量的调度程序,但您不能为此使用默认的石英配置方法,因为它只需要一个 collection 调度程序属性(查看 StdSchedulerFactory
implementation and this 博客(如果有趣的话):
By default, In Quartz.Net, the StdSchedulerFactory is responsible for configuring the scheduler. When the Quartz.Net scheduler is started, the factory will try to automatically configure a scheduler by looking for configuration information in different places:
- the hosting application’s configuration file
- a file specified in an environment variable
- the quartz.config file
- the embedded configuration file
所以你可以做的不是使用自动调度程序配置,而是
自己创建一个单独的 collection 属性并将它们传递给调度程序创建构造函数:
public StdSchedulerFactory(NameValueCollection props);
使用代码方法:
NameValueCollection scheduler1Properties = new NameValueCollection(); properties["quartz.scheduler.instanceName"] = "SingleThreadScheduler"; properties["quartz.threadPool.type"] = "Quartz.Simpl.SimpleThreadPool, Quartz"; properties["quartz.threadPool.threadCount"] = "1"; ... var factory = new StdSchedulerFactory(scheduler1Properties);
或者您可以创建单独的石英配置并直接使用石英 PropertiesParser class 读取
/// <summary> /// Reads the properties from file system. /// </summary> /// <param name="fileName">The file name to read resources from.</param> /// <returns></returns> public static PropertiesParser ReadFromFileResource(string fileName)
并得到 collection:
/// <summary> /// Gets the underlying properties. /// </summary> /// <value>The underlying properties.</value> public virtual NameValueCollection UnderlyingProperties { get { return props; } }
//
PropertiesParser
class直接用于default配置读取实现