当前位置:网站首页>Using quartz under. Net core -- general properties and priority of triggers for [5] jobs and triggers
Using quartz under. Net core -- general properties and priority of triggers for [5] jobs and triggers
2022-04-23 17:11:00 【Tomato Warrior】
The knowledge points related to homework are over , The following will focus on learning triggers
1、 General properties of triggers :
All triggers have the following three properties
JobKey
The attribute represents , Trigger firing , Unique identification of the job that should be executed ( Operational key)
StartTimeUtc
Property indicates when the trigger's schedule first takes effect ( The value is DateTimeOffset object )
EndTimeUtc
Property indicates when the trigger's schedule is no longer valid
The following is a complete code demonstration
Startup.cs
public void ConfigureServices(IServiceCollection services)
{
services.AddControllersWithViews();
// Register scheduler factory
services.AddSingleton<ISchedulerFactory>(new StdSchedulerFactory());
}
HomeController.cs
using Microsoft.AspNetCore.Mvc;
using Quartz;
using System;
using System.Threading.Tasks;
namespace QuartzLearn.Controllers
{
public class HomeController : Controller
{
// Dispatcher factory
private readonly ISchedulerFactory _schedulerFactory;
// Constructor injection
public HomeController(ISchedulerFactory schedulerFactory)
{
// Injection scheduler factory
_schedulerFactory = schedulerFactory;
}
public async Task<IActionResult> Index()
{
IScheduler scheduler = await _schedulerFactory.GetScheduler();
await scheduler.Start();
IJobDetail job = JobBuilder.Create<HelloJob>()
.WithIdentity("job1", "jobGroup1")
.UsingJobData("name", "zhangsan")
.Build();
// Trigger once in the next five minutes
ITrigger trigger = TriggerBuilder.Create()
.WithIdentity("trigger1", "group1")
.StartAt(DateBuilder.FutureDate(5, IntervalUnit.Minute))
.EndAt(DateBuilder.DateOf(22, 0, 0))
.Build();
await scheduler.ScheduleJob(job, trigger);
Console.WriteLine($" current time :{trigger.StartTimeUtc.DateTime}");
Console.WriteLine($" First trigger start time : {trigger.StartTimeUtc.DateTime}");
Console.WriteLine($" Trigger failure time : {trigger.EndTimeUtc?.DateTime}");
Console.WriteLine($" Executed when triggered Job: {trigger.JobKey}");
return View();
}
}
[DisallowConcurrentExecution]
[PersistJobDataAfterExecution]
public class HelloJob : IJob
{
public string Name { private get; set; }
public async Task Execute(IJobExecutionContext context)
{
await Console.Out.WriteLineAsync($"This is HelloJob {DateTime.Now}");
}
}
}
Execution results :
2、 The priority of the trigger :
The default value of trigger priority is 5
The priority is compared only if the trigger has the same trigger time . Plan in 10:59 The trigger triggered will always be planned in 11:00 Trigger before trigger .
Don't make too many presentations
版权声明
本文为[Tomato Warrior]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230553457774.html
边栏推荐
- JSON deserialize anonymous array / object
- [C#] 彻底搞明白深拷贝
- ASP. NET CORE3. 1. Solution to login failure after identity registers users
- VsCode-Go
- feign报400处理
- Wiper component encapsulation
- 1-3 components and modules
- Decimal format decimal / datetime conversion processing
- Nodejs installation and environment configuration
- STM32__ 03 - beginner timer
猜你喜欢
快时钟同步慢时钟域下的异步控制信号slow clk to fast clk
[pimf] openharmony paper Club - what is the experience of wandering in ACM survey
The new MySQL table has a self increasing ID of 20 bits. The reason is
RTKLIB 2.4.3源码笔记
EF core in ASP Generate core priority database based on net entity model
Customize my_ Strcpy and library strcpy [analog implementation of string related functions]
[PROJECT] small hat takeout (8)
ASP. NET CORE3. 1. Solution to login failure after identity registers users
文件操作《二》(5000字总结篇)
Feign report 400 processing
随机推荐
Decimal format decimal / datetime conversion processing
Further optimize Baidu map data visualization
Read a blog, re understand closures and tidy up
Multithreaded @ async thread pool
Blue Bridge Cup provincial road 06 -- the second game of the 12th provincial competition
MySQL restores data through binlog file
Zhimeng dedecms security setup Guide
ASP. NET CORE3. 1. Solution to login failure after identity registers users
Interface document yaml
Document operation II (5000 word summary)
C listens for WMI events
[registration] tf54: engineer growth map and excellent R & D organization building
Freecodecamp ---- budget & category exercise
Paging the list collection
ASP. Net core dependency injection service life cycle
ASP. Net core configuration options (Part 2)
Nodejs reads the local JSON file through require. Unexpected token / in JSON at position appears
Linux MySQL data timing dump
Milvus 2.0 质量保障系统详解
【生活中的逻辑谬误】稻草人谬误和无力反驳不算证明