当我尝试时,我有一个需要渲染 GSP 的石英作业:
def g = new org.codehaus.groovy.grails.plugins.web.taglib.ApplicationTagLib()
def text = g.render(template: "/templates/myTemplate",
model: [language: language,
product: product])
Run Code Online (Sandbox Code Playgroud)
我收到以下异常:
org.quartz.JobExecutionException: No thread-bound request found: Are you referring to request attributes outside of an actual web request, or processing a request outside of the originally receiving thread? If you are actually operating within a web request and still receive this message, your code is probably running outside of DispatcherServlet/DispatcherPortlet: In this case, use RequestContextListener or RequestContextFilter to expose the current request. …Run Code Online (Sandbox Code Playgroud) java Quartz Scheduler是否支持异步作业调度。如果支持,是默认的还是必须自定义作业才能异步运行。
有什么方法可以从 Quartz.NET 作业访问 HttpContext 对象吗?HttpContext.Current 等似乎不适用于 Quartz.NET 作业。
我们有一个托管在 IIS 8.0 上的 Intranet 应用程序。
\n\n我们有一些可用的 Web 方法,需要在特定时间执行。
\n\n因此,我们使用 Quartz 调度程序来调度执行 Web 方法的作业。在global.asax的Application_Start事件中,我们编写了启动调度程序的代码。
\n\n为了保持调度程序正常运行,应用程序池应该始终处于运行模式,因此我们设置了属性 startMode=\xe2\x80\x9cAlwaysRunning\xe2\x80\x9d 并且应用程序应该启动,因此我们设置了应用程序属性 preloadEnabled=\xe2\x80\x9cTrue\xe2\x80\x9d。
\n\n我们每 1740 分钟(29 小时,默认时间)回收一次应用程序池。
\n\n这里的问题是:
\n\n如果我有工作安排在凌晨 3:00。我的应用程序池处于运行状态。
\n\n我在预定时间前一天的下午 6:00 浏览了该应用程序。
\n\n根据回收时间,我的应用程序池已在凌晨 2:00 回收,直到凌晨 3:00,我的应用程序都未 ping 通,但我的应用程序池处于运行状态。
\n\n当应用程序池被回收时,应用程序池将再次启动(因为属性startMode=\xe2\x80\x9cAlwaysRunning\xe2\x80\x9d),但进程ID(如果该工作进程会不同)。
\n\n由于应用程序池的回收,quartz 没有按照计划执行作业。如果我在回收应用程序池后浏览应用程序,那么quartz将按照计划执行作业。
\n\n有人可以尽早帮我解决这个问题吗?
\n\n感谢期待。
\n我无法理解如何使用 Quartz 2.3.2 版获取作业的详细信息。
到目前为止,我们使用 Quartz v1.0.x 进行作业,我必须将其升级到最新版本。
这是我们过去获取作业详细信息的方式:
JobDetail job = scheduler.GetJobDetail(task.Name, groupName);
Run Code Online (Sandbox Code Playgroud)
在 2.3.2 版本中,该方法GetJobDetail()不再具有接受 2 个参数的构造函数......相反,它接受一个JobKey参数。
不幸的是,我找不到获得单个 JobKey 的方法。我尝试的是以下内容:
string groupName = !string.IsNullOrEmpty(task.GroupNameExtension) ? task.GroupNameExtension : task.GroupName;
var jobkeys = quartzScheduler.GetJobKeys(GroupMatcher<JobKey>.GroupContains(groupName));
var jobkey = jobkeys.Single(x => x.Name == task.Name);
var jobDetail = quartzScheduler.GetJobDetail(jobkey);
Run Code Online (Sandbox Code Playgroud)
var jobkey = jobkey.Single(...)吗?提前致谢
我使用带有 cron 表达式的 spring 调度程序
*/5 * * * * ?
(每 5 秒一次)。上个月都用了,最近两天突然停了。
再次重新启动服务器后,它工作正常。
有什么区别吗
*/5 * * * * ?
*/5 * * * * *
? 它基于任何月份。
那么是什么意思呢?这里。想知道停止的原因吗?
提前致谢。
为了提高石英的性能,我打算按照石英调度程序的性能调优中的建议在石英中使用批处理
我们创建了与 spring 集成的石英调度程序,如下所示。
<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<!-- Quartz requires a separate 'quartz.properties' file -->
<property name="configLocation" value="classpath:/quartz.properties"/>
<!-- Naturally, Quartz with the DB requires references
to the data source and transaction manager beans -->
<property name="dataSource" ref="quartzDataSource"/>
<!--<property name="transactionManager" ref="transactionManager"/>-->
<!-- reference to our 'autowiring job factory bean', defined above: -->
<property name="jobFactory" ref="quartzJobFactory"/>
<!-- Boolean controlling whether you want to override
the job definitions in the DB on the app start up.
We'll talk about it more …Run Code Online (Sandbox Code Playgroud) 我有一个 spring boot 项目,我想使用石英在特定时间运行某些作业。我有这个班级布局:
abstract public class AbstractFoo {
protected final FooB fooB;
public AbstractFoo(FooB fooB) {
this.fooB = fooB;
}
}
@Service
public class SomeJob extends AbstractFoo implements Job {
public SomeJob(FooB fooB) {
super(fooB);
}
@Override
public void execute(final JobExecutionContext context) throws JobExecutionException {
//do stuff
}
}
Run Code Online (Sandbox Code Playgroud)
但是,当我运行此作业时,出现以下错误:
2017-12-06 14:18:01,383 ERROR --- [quartz-jobs] org.quartz.core.ErrorLogger : An error occured instantiating job to be executed. job= 'jobGroup.someJob'
org.quartz.SchedulerException: Job instantiation failed
at org.springframework.scheduling.quartz.AdaptableJobFactory.newJob(AdaptableJobFactory.java:45)
at org.quartz.core.JobRunShell.initialize(JobRunShell.java:127)
at org.quartz.core.QuartzSchedulerThread.run(QuartzSchedulerThread.java:375)
Caused by: …Run Code Online (Sandbox Code Playgroud) 我想根据用户从 UI 提供的调度配置动态调度作业。当用户从 UI 保存新的计划配置时,流程必须使用新的计划参数调用新作业。可以有 n 个配置来执行相同的作业。Spring 支持 job detail 和 trigger 的实现如下。
定义jobdetail:
@Bean
public JobDetail jobDetail() {
return JobBuilder.newJob().ofType(SampleJob.class)
.storeDurably()
.withIdentity("Qrtz_Job_Detail")
.withDescription("Invoke Sample Job service...")
.build();
}
Run Code Online (Sandbox Code Playgroud)
定义触发器:
@Bean
public Trigger trigger(JobDetail job) {
return TriggerBuilder.newTrigger().forJob(job)
.withIdentity("Qrtz_Trigger")
.withDescription("Sample trigger")
.withSchedule(simpleSchedule().repeatForever().withIntervalInHours(1))
.build();
}
Run Code Online (Sandbox Code Playgroud)
如何根据用户提供的参数动态传递job明细参数和触发?
我正在将 SpringBoot 2.1.5 与 Quartz Starter 一起使用。
这是我的工作
@Slf4j
public class LogJob extends QuartzJobBean {
@Override
protected void executeInternal(JobExecutionContext jobExecutionContext) throws JobExecutionException {
log.info("hello world");
}
}
Run Code Online (Sandbox Code Playgroud)
只是一个非常简单的工作,它会记录一些消息。
然后,它们是我的配置 bean:
@Configuration
public class QuartzJobConfig {
@Bean
public JobDetail issuesSyncJobDetail(){
return JobBuilder.newJob(LogJob.class)
.withIdentity("vue", "vuejsJob")
.build();
}
@Bean
public Trigger triggerIssuesJob(JobDetail jobDetail){
int interval = 2;
SimpleScheduleBuilder scheduleBuilder = SimpleScheduleBuilder
.simpleSchedule().withIntervalInSeconds(interval).repeatForever();
return TriggerBuilder.newTrigger()
.forJob(jobDetail)
.withIdentity("vue","vuejsTrigger")
.withSchedule(scheduleBuilder).startNow().build();
}
}
Run Code Online (Sandbox Code Playgroud)
我创建了一个 JobDetatil Bean 和一个触发器,我希望它可以工作。
但是当我开始我的项目时,它会抛出一个错误
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'quartzScheduler' defined in …Run Code Online (Sandbox Code Playgroud) quartz-scheduler ×10
java ×5
spring ×5
quartz.net ×3
spring-boot ×2
.net ×1
c# ×1
grails ×1
iis-8 ×1
quartz ×1
scheduler ×1