- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用javaquartz调度。我能够完美地安排作业,但我想要的是在运行第二轮之前等待作业完成,因为运行每个作业所需的时间各不相同。
我使用了@DisallowConcurrentExecution,它所做的只是让作业运行一次,不再运行。从作业监听器显示该作业已成功完成一次。
Job
=============================================================
@DisallowConcurrentExecution
public class SalesJob implements Job{
List<Transaction> unsentTransaction = new ArrayList<Transaction>();
List<Sale> sales = new ArrayList<Sale>();
public void execute(JobExecutionContext jec) throws JobExecutionException {
System.out.println("Sales Job. . .");
}
}
作业监听器:
public class SalesJobListener implements JobListener{
public static final String LISTENER_NAME = "dummyJobListenerName";
public String getName() {
return LISTENER_NAME;
}
public void jobToBeExecuted(JobExecutionContext context) {
String jobName = context.getJobDetail().getKey().toString();
System.out.println("jobToBeExecuted");
System.out.println("Job : " + jobName + " is going to start...");
}
public void jobExecutionVetoed(JobExecutionContext jec) {
System.out.println("jobExecutionVetoed");
}
public void jobWasExecuted(JobExecutionContext context, JobExecutionException jobException) {
System.out.println("jobWasExecuted");
String jobName = context.getJobDetail().getKey().toString();
System.out.println("Job : " + jobName + " is finished...");
System.out.println("=====================================");
System.out.println("==========" + new Date() + "===========");
if (!jobException.getMessage().equals("")) {
System.out.println(
"Exception thrown by: " + jobName + " Exception: " + jobException.getMessage());
}
}
}
这是时间表
JobKey salesJobKey = new JobKey("salesJob", "group1");
JobDetail salesJob = JobBuilder.newJob(SalesJob.class)
.withIdentity(salesJobKey).build();
Trigger salesTrigger = TriggerBuilder
.newTrigger()
.withIdentity("salesTrigger", "group1")
.withSchedule(
CronScheduleBuilder.cronSchedule("0/5 * * * * ?"))
.build();
Scheduler scheduler = new StdSchedulerFactory().getScheduler();
scheduler.getListenerManager().addJobListener(
new SalesJobListener(), KeyMatcher.keyEquals(salesJobKey)
);
scheduler.start();
scheduler.scheduleJob(salesJob, salesTrigger);
最佳答案
问题
it executed this time, Wed Nov 25 12:01:15 EAT 2015 and now is Wed Nov 25 12:32 2015, so basically i have waited > 30 mins. . . and there is no another job
这就是说调度程序
不起作用。
为什么?
0/5 * * * * ?
使调度程序仅在第 0 秒和第 5 秒运行每分钟。@DisallowConcurrentExecution
将阻止执行作业。解决方案:
错误在于您的代码顺序,您在告诉它必须安排作业之前执行调度程序 (scheduler.start();
) (scheduler.scheduleJob(salesJob, salesTrigger);
):
scheduler.start();
scheduler.scheduleJob(salesJob, salesTrigger);
检查this example并交换你的线路:
scheduler.scheduleJob(salesJob, salesTrigger);
scheduler.start();
就这些了...
关于java - Quartz @DisallowConcurrentExecution 未按预期工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33912724/
我一直在研究一个调度引擎,它从数据库中读取计划作业并安排它们工作正常,但是数据库中的行只是某些类型作业的“配置”,例如: 获取FTP的一定配置有 host: imagineryHost1.com po
我正在使用javaquartz调度。我能够完美地安排作业,但我想要的是在运行第二轮之前等待作业完成,因为运行每个作业所需的时间各不相同。 我使用了@DisallowConcurrentExecutio
您好,我有两个 quartz 作业实例,我不想并行运行,我简化了下面示例中的代码以显示哪些内容不符合我的预期。 public class QuartzTest { public static void
如果这个问题太天真,我很抱歉,我希望安排作业,以便它一个接一个地执行,而不是并行执行。它只执行一次。 从文档来看,@DisallowConcurrentExecution 是 一种注释,将 {@lin
当一个作业因为 disallow 注释而没有运行时会发生什么。 它是否在当前正在运行的实例死亡后排队运行?是否只是丢弃了它的重复“运行”,再也听不到了? 我尝试过在代码中进行测试,但我对语言和库的缺乏
我已经开发了一些执行 quartz 作业的代码。起初代码在 tomcat 之外并且执行得很好,但是当我尝试将相同的代码嵌入到 Web 应用程序中时,我得到了 java.lang.NoClassDefF
请考虑这个例子。 一个示例 Web 应用程序在启动时调用 scheduler.start()。配置为将其作业存储在数据库中的调度程序。 应用程序被复制到六个网络服务器上。 因此,如果我们启动六个网络服
我有一个具有以下定义的 Quartz.net 作业。 [PersistJobDataAfterExecution] [DisallowConcurrentExecution]
如果我使用 JdbcStore 将作业代码部署在两个 JVM 上,@DisallowConcurrentExecution 能否确保所有 JVM 上仅运行一个作业? 最佳答案 是的,会的;这种属性甚至
我是一名优秀的程序员,十分优秀!