run
/*
* Copyright 2005 - 2009 Terracotta, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy
* of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
*/
package com.tht.common.quartz;
import java.util.Date;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.quartz.CronTrigger;
import org.quartz.JobDetail;
import org.quartz.Scheduler;
import org.quartz.SchedulerFactory;
import org.quartz.SchedulerMetaData;
import org.quartz.impl.StdSchedulerFactory;
import com.tht.common.properties.PropertiesUtil;
/**
* This Example will demonstrate all of the basics of scheduling capabilities of
* Quartz using Cron Triggers.
*
* @author Bill Kratzer
*/
public class Run {
static Logger log = LoggerFactory.getLogger(Run.class);
public void run() throws Exception {
// First we must get a reference to a scheduler
SchedulerFactory sf = new StdSchedulerFactory();
Scheduler sched = sf.getScheduler();
// jobs can be scheduled before sched.start() has been called
JobDetail job =null;
CronTrigger trigger=null;
Date ft =null;
String strExpression=PropertiesUtil.getProperties("properties/run.properties").getProperty("timing");
job = new JobDetail("job3", "group1", SimpleJob.class);
/*
trigger = new CronTrigger("trigger3", "group1", "job3", "group1",
"0 0/1 8-18 * * ?");
*/
/* trigger = new CronTrigger("trigger3", "group1", "job3", "group1",
"0/20 * * * * ?");*/
trigger = new CronTrigger("trigger3", "group1", "job3", "group1",strExpression);
sched.addJob(job, true);
ft = sched.scheduleJob(trigger);
log.info(job.getFullName() + " has been scheduled to run at: " + ft
+ " and repeat based on expression: "
+ trigger.getCronExpression());
sched.start();
}
public static void main(String[] args) throws Exception {
Run example = new Run();
example.run();
}
}
simple job
/*
* Copyright 2005 - 2009 Terracotta, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy
* of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
*/
package com.tht.common.quartz;
import java.util.Date;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
/**
* <p>
* This is just a simple job that gets fired off many times by example 1
* </p>
*
* @author Bill Kratzer
*/
public class SimpleJob implements Job {
private static Logger _log = LoggerFactory.getLogger(SimpleJob.class);
/**
* Quartz requires a public empty constructor so that the
* scheduler can instantiate the class whenever it needs.
*/
public SimpleJob() {
}
/**
* <p>
* Called by the <code>{@link org.quartz.Scheduler}</code> when a
* <code>{@link org.quartz.Trigger}</code> fires that is associated with
* the <code>Job</code>.
* </p>
*
* @throws JobExecutionException
* if there is an exception while executing the job.
*/
public void execute(JobExecutionContext context)
throws JobExecutionException {
// This job simply prints out its job name and the
// date and time that it is running
String jobName = context.getJobDetail().getFullName();
_log.info("Project start: " + jobName + " executing at " + new Date());
String[] strs={""};
System.out.println("执行了");
}
}
分享到:
相关推荐
MB QUART DSP调音软件是专为汽车音响爱好者和专业技师设计的一款高级音频处理工具,主要用于优化车载音响系统的音质表现。MB QUART是一家知名的德国音响品牌,以其高质量的音频设备而闻名。这款DSP(Digital Signal ...
Quart 是一个基于 Python 的异步 Web 框架,它是 Flask 框架的asyncio版本,设计用于构建高性能的、可扩展的Web服务。Quart 的出现是为了满足现代Web应用对高并发处理的需求,它利用了Python 3.5及以上版本中的...
标题中的“spring、Quart 源码”指的是Spring框架和Quartz库的源代码,这两个都是Java领域中用于构建应用程序的重要组件。Spring是全面的企业级应用开发框架,而Quartz则是一个强大的任务调度库。 Spring框架是Java...
资源分类:Python库 所属语言:Python 使用前提:需要解压 资源全名:Quart_CORS-0.3.0-py3-none-any.whl 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
QuartJob简介 1、一句话描述 Quartz是一个完全由java编写的开源作业调度框架,形式简易,功能强大。 2、核心API (1)、Scheduler 代表一个 Quartz 的独立运行容器,Scheduler 将 Trigger 绑定到特定 JobDetail, ...
### Quart-Z 两次执行问题详解 #### 一、问题背景及概述 在处理Quart-Z定时任务时,可能会遇到一个常见的问题:定时任务被意外执行了两次。此问题的出现通常与部署环境有关,尤其是当应用程序部署在Tomcat服务器上...
Quartz 2D是苹果操作系统中的一个二维图形渲染引擎,用于在iOS和macOS平台上创建高质量的图形。它提供了一套强大的API,让开发者能够直接控制像素级别的绘图,实现复杂的图形绘制和图像处理。本篇文章将深入探讨...
资源分类:Python库 所属语言:Python 资源全名:Quart-Trio-0.5.1.tar.gz 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
Spring Quartz 是一个强大的任务调度框架,它允许开发者在Spring应用中定义定时任务,实现复杂的调度需求。本示例提供了一个关于如何在Spring中使用Quartz的简单实例,包含全部的代码和配置文件,展示了多种定时任务...
Quart定时任务是一种基于Java的开源作业调度框架,它允许应用程序定义和执行重复的任务。Quartz的核心特性包括灵活的调度,支持多种触发器(如SimpleTrigger、CronTrigger)以及可扩展的工作(Job)。在本项目中,...
**Python库Quart-Compress 0.2.1详解** 在Python的Web开发领域,Flask和Django等框架非常流行,而Quart则是一个针对异步应用的框架,它模仿了Flask的设计,提供了对asyncio的支持,使得开发者能够充分利用多核CPU的...
在Java开发中,Spring框架是应用最广泛的IoC(Inversion of Control)和AOP(Aspect Oriented Programming)容器,而Quartz则是广泛使用的任务调度库。本示例讲解了如何利用Spring管理Quartz实现定时任务,无需在`...
Quart-openapi是一个针对Python的Quart框架的扩展模块,其设计目的是为了提供与Flask-RESTPlus类似的功能。Quart本身是基于asyncio的Web服务框架,它允许开发人员利用Python 3的异步特性来构建高性能的Web应用。...
Quart-Session-OpenID 向您的Quart应用程序添加OpenID Connect支持。 支持以下OAuth2流: 机密-授权代码流 公开-隐式授予(SPA:VueJS,Angular,React等) 除非另有说明,否则此扩展假定OIDC提供程序为 。 已知...
夸脱 Quart是一个异步Python网络微框架。 使用Quart,您可以呈现并提供HTML模板, 编写(RESTful)JSON API, 服务WebSocket, 流请求和响应数据, 通过HTTP或WebSocket协议执行几乎所有操作。快速开始Quart可以通过...
本文将深入探讨“gino-quart-0.1.1b3.tar.gz”这一Python库,它是Python开发中的两个重要组件——Gino和Quart的结合。 首先,我们来了解Gino。Gino是“Go Inspired Not Only ORM”的缩写,它是一个轻量级、异步的...
Quart是一个Python实现的异步Web服务器网关接口(ASGI)应用,模仿了 Flask 的 API,但增加了对异步处理的支持,使开发者能够充分利用现代多核硬件的优势。 速率限制在Web服务中扮演着重要的角色,它可以帮助保护...