本文整理汇总了Java中org.springframework.scheduling.quartz.SchedulerFactoryBean.setQuartzProperties方法的典型用法代码示例。如果您正苦于以下问题:Java SchedulerFactoryBean.setQuartzProperties方法的具体用法?Java SchedulerFactoryBean.setQuartzProperties怎么用?Java SchedulerFactoryBean.setQuartzProperties使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.scheduling.quartz.SchedulerFactoryBean
的用法示例。
在下文中一共展示了SchedulerFactoryBean.setQuartzProperties方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: schedulerFactoryBean
import org.springframework.scheduling.quartz.SchedulerFactoryBean; //导入方法依赖的package包/类
@Bean
public SchedulerFactoryBean schedulerFactoryBean(DataSource dataSource) {
SchedulerFactoryBean factory = new SchedulerFactoryBean();
factory.setDataSource(dataSource);
//quartz参数
Properties prop = new Properties();
prop.put("org.quartz.scheduler.instanceName", "RenrenScheduler");
prop.put("org.quartz.scheduler.instanceId", "AUTO");
//线程池配置
prop.put("org.quartz.threadPool.class", "org.quartz.simpl.SimpleThreadPool");
prop.put("org.quartz.threadPool.threadCount", "20");
prop.put("org.quartz.threadPool.threadPriority", "5");
//JobStore配置
prop.put("org.quartz.jobStore.class", "org.quartz.impl.jdbcjobstore.JobStoreTX");
//集群配置
// prop.put("org.quartz.jobStore.isClustered", "true");
// prop.put("org.quartz.jobStore.clusterCheckinInterval", "15000");
// prop.put("org.quartz.jobStore.maxMisfiresToHandleAtATime", "1");
prop.put("org.quartz.jobStore.misfireThreshold", "12000");
prop.put("org.quartz.jobStore.tablePrefix", "QRTZ_");
factory.setQuartzProperties(prop);
factory.setSchedulerName("RenrenScheduler");
//延时启动
factory.setStartupDelay(30);
factory.setApplicationContextSchedulerContextKey("applicationContextKey");
//可选,QuartzScheduler 启动时更新己存在的Job,这样就不用每次修改targetObject后删除qrtz_job_details表对应记录了
factory.setOverwriteExistingJobs(true);
//设置自动启动,默认为true
factory.setAutoStartup(true);
return factory;
}
示例2: schedulerFactory
import org.springframework.scheduling.quartz.SchedulerFactoryBean; //导入方法依赖的package包/类
@Bean
public SchedulerFactoryBean schedulerFactory(JobFactory jobFactory) {
SchedulerFactoryBean schedulerFactoryBean = new SchedulerFactoryBean();
schedulerFactoryBean.setApplicationContext(applicationContext);
schedulerFactoryBean.setAutoStartup(schedulerProperties.isAutoStartup());
schedulerFactoryBean.setDataSource(dataSource);
schedulerFactoryBean.setTransactionManager(platformTransactionManager);
schedulerFactoryBean.setOverwriteExistingJobs(schedulerProperties.isOverwriteExistingJobs());
schedulerFactoryBean.setSchedulerFactoryClass(StdSchedulerFactory.class);
schedulerFactoryBean.setBeanName(schedulerProperties.getBeanName());
schedulerFactoryBean.setJobFactory(jobFactory);
schedulerFactoryBean.setWaitForJobsToCompleteOnShutdown(schedulerProperties.isWaitOnShutdown());
schedulerFactoryBean.setQuartzProperties(schedulerProperties.getProperties());
schedulerFactoryBean.setStartupDelay(schedulerProperties.getStartupDelay());
schedulerFactoryBean.setCalendars(calendarMap);
schedulerFactoryBean.setSchedulerListeners(schedulerListeners);
return schedulerFactoryBean;
}
示例3: schedulerFactoryBean
import org.springframework.scheduling.quartz.SchedulerFactoryBean; //导入方法依赖的package包/类
/**
* create scheduler
*/
@Bean
public SchedulerFactoryBean schedulerFactoryBean() throws IOException {
SchedulerFactoryBean factory = new SchedulerFactoryBean();
factory.setOverwriteExistingJobs(true);
factory.setDataSource(dataSource);
factory.setQuartzProperties(quartzProperties());
//Register listeners to get notification on Trigger misfire etc
factory.setGlobalTriggerListeners(triggerListner);
factory.setGlobalJobListeners(jobsListener);
AutowiringSpringBeanJobFactory jobFactory = new AutowiringSpringBeanJobFactory();
jobFactory.setApplicationContext(applicationContext);
factory.setJobFactory(jobFactory);
return factory;
}
示例4: schedulerFactoryBean
import org.springframework.scheduling.quartz.SchedulerFactoryBean; //导入方法依赖的package包/类
@Bean
public SchedulerFactoryBean schedulerFactoryBean(
DataSource dataSource, PlatformTransactionManager transactionManager, JobFactory jobFactory) {
final SchedulerFactoryBean factory = new SchedulerFactoryBean();
factory.setOverwriteExistingJobs(true);
factory.setTaskExecutor(commonTaskScheduler.getScheduledExecutor());
factory.setDataSource(dataSource);
factory.setTransactionManager(transactionManager);
factory.setJobFactory(jobFactory);
factory.setQuartzProperties(quartzProperties);
factory.setSchedulerName(SCHEDULER_NAME);
factory.setAutoStartup(true);
factory.setWaitForJobsToCompleteOnShutdown(true);
// Delay added to avoid errors caused by updating registered tasks and reduce load on startup
factory.setStartupDelay(30);
return factory;
}
示例5: schedulerFactory
import org.springframework.scheduling.quartz.SchedulerFactoryBean; //导入方法依赖的package包/类
@Bean
public SchedulerFactoryBean schedulerFactory(JobFactory jobFactory) throws IOException {
SchedulerFactoryBean factory = new SchedulerFactoryBean();
factory.setSchedulerName("Sentry");
factory.setJobFactory(jobFactory);
factory.setQuartzProperties(quartzProperties());
// this allows to update triggers in DB when updating settings in config file:
factory.setOverwriteExistingJobs(true);
return factory;
}
示例6: schedulerFactoryBean
import org.springframework.scheduling.quartz.SchedulerFactoryBean; //导入方法依赖的package包/类
@Bean
public SchedulerFactoryBean schedulerFactoryBean(DataSource dataSource) {
SchedulerFactoryBean factory = new SchedulerFactoryBean();
factory.setDataSource(dataSource);
//quartz参数
Properties prop = new Properties();
prop.put("org.quartz.scheduler.instanceName", "JxteleScheduler");
prop.put("org.quartz.scheduler.instanceId", "AUTO");
//线程池配置
prop.put("org.quartz.threadPool.class", "org.quartz.simpl.SimpleThreadPool");
prop.put("org.quartz.threadPool.threadCount", "20");
prop.put("org.quartz.threadPool.threadPriority", "5");
//JobStore配置
prop.put("org.quartz.jobStore.class", "org.quartz.impl.jdbcjobstore.JobStoreTX");
//集群配置
prop.put("org.quartz.jobStore.isClustered", "true");
prop.put("org.quartz.jobStore.clusterCheckinInterval", "15000");
prop.put("org.quartz.jobStore.maxMisfiresToHandleAtATime", "1");
prop.put("org.quartz.jobStore.misfireThreshold", "12000");
prop.put("org.quartz.jobStore.tablePrefix", "QRTZ_");
factory.setQuartzProperties(prop);
factory.setSchedulerName("RenrenScheduler");
//延时启动
factory.setStartupDelay(30);
factory.setApplicationContextSchedulerContextKey("applicationContextKey");
//可选,QuartzScheduler 启动时更新己存在的Job,这样就不用每次修改targetObject后删除qrtz_job_details表对应记录了
factory.setOverwriteExistingJobs(true);
//设置自动启动,默认为true
factory.setAutoStartup(true);
return factory;
}
示例7: getEventHealthMonitorBean
import org.springframework.scheduling.quartz.SchedulerFactoryBean; //导入方法依赖的package包/类
@Bean
public SchedulerFactoryBean getEventHealthMonitorBean(){
SchedulerFactoryBean bean = new SchedulerFactoryBean();
bean.setBeanName("EventHealthMonitorThread");
bean.setTriggers(new Trigger [] {getMonitorJobTrigger().getObject()});
Properties prop = new Properties();
prop.setProperty("org.quartz.threadPool.class", "org.quartz.simpl.SimpleThreadPool");
prop.setProperty("org.quartz.threadPool.threadCount", "1");
bean.setQuartzProperties(prop);
return bean;
}
示例8: getEventJobBean
import org.springframework.scheduling.quartz.SchedulerFactoryBean; //导入方法依赖的package包/类
@Bean
public SchedulerFactoryBean getEventJobBean(){
SchedulerFactoryBean bean = new SchedulerFactoryBean();
bean.setBeanName("EligibleEventProcessorThread");
bean.setTriggers(new Trigger [] {getEventJobTrigger().getObject()});
Properties prop = new Properties();
prop.setProperty("org.quartz.threadPool.class", "org.quartz.simpl.SimpleThreadPool");
prop.setProperty("org.quartz.threadPool.threadCount", "1");
bean.setQuartzProperties(prop);
return bean;
}
示例9: mainScheduler
import org.springframework.scheduling.quartz.SchedulerFactoryBean; //导入方法依赖的package包/类
@Bean(name = "mainScheduler")
public SchedulerFactoryBean mainScheduler(DelegatingQuartzJobFactory jobFactory,
@Qualifier("quartzProperties") Properties quartzProperties,
@Value("#{'${cronyx.passive}'=='true'}") boolean passive,
@Qualifier("cronyxDataSource") DataSource dataSource){
SchedulerFactoryBean factory = new SchedulerFactoryBean();
factory.setJobFactory(jobFactory);
factory.setQuartzProperties(quartzProperties);
factory.setDataSource(dataSource);
factory.setAutoStartup(!passive);
factory.setSchedulerName(quartzProperties.getProperty(PROP_SCHED_INSTANCE_NAME));
return factory;
}
示例10: init
import org.springframework.scheduling.quartz.SchedulerFactoryBean; //导入方法依赖的package包/类
@Override
public void init(ComponentRepository repo, LinkedHashMap<String, String> configuration) throws Exception {
ComponentInfo info = new ComponentInfo(Scheduler.class, getClassifier());
Properties quartzProperties = new Properties();
quartzProperties.setProperty(StdSchedulerFactory.PROP_SCHED_JMX_EXPORT, "true");
quartzProperties.setProperty(StdSchedulerFactory.PROP_SCHED_SKIP_UPDATE_CHECK, "true");
SchedulerFactoryBean schedulerBean = new SchedulerFactoryBean();
schedulerBean.setWaitForJobsToCompleteOnShutdown(true);
schedulerBean.setQuartzProperties(quartzProperties);
repo.registerComponent(info, schedulerBean);
repo.registerLifecycle(schedulerBean);
}
示例11: getSchedulerFactoryBean
import org.springframework.scheduling.quartz.SchedulerFactoryBean; //导入方法依赖的package包/类
/**
* Gets the scheduler factory bean.
*
* @param appStatsTrigger the app stats trigger
* @param clusterStatsTrigger the cluster stats trigger
* @param connectorStatsTrigger the connector stats trigger
* @param datasourceStatsTrigger the datasource stats trigger
* @param memoryStatsTrigger the memory stats trigger
* @param runtimeStatsTrigger the runtime stats trigger
* @param statsSerializerTrigger the stats serializer trigger
* @return the scheduler factory bean
*/
@Bean(name = "scheduler")
public SchedulerFactoryBean getSchedulerFactoryBean(@Autowired AppStatsTrigger appStatsTrigger,
@Autowired ClusterStatsTrigger clusterStatsTrigger,
@Autowired ConnectorStatsTrigger connectorStatsTrigger,
@Autowired DatasourceStatsTrigger datasourceStatsTrigger,
@Autowired MemoryStatsTrigger memoryStatsTrigger,
@Autowired RuntimeStatsTrigger runtimeStatsTrigger,
@Autowired StatsSerializerTrigger statsSerializerTrigger) {
logger.debug("Instantiated scheduler");
SchedulerFactoryBean bean = new SchedulerFactoryBean();
// Add Triggers
bean.setTriggers(appStatsTrigger.getObject(), clusterStatsTrigger.getObject(),
connectorStatsTrigger.getObject(), datasourceStatsTrigger.getObject(),
memoryStatsTrigger.getObject(), runtimeStatsTrigger.getObject(),
statsSerializerTrigger.getObject());
// Add Properties
Properties properties = new Properties();
properties.setProperty("org.quartz.scheduler.instanceName", "ProbeScheduler");
properties.setProperty("org.quartz.threadPool.threadCount", "5");
properties.setProperty("org.quartz.threadPool.threadNamePrefix", "Probe_Quartz");
bean.setQuartzProperties(properties);
return bean;
}
示例12: init
import org.springframework.scheduling.quartz.SchedulerFactoryBean; //导入方法依赖的package包/类
/**
* Creates the Spring {@code SchedulerFactoryBean}.
*/
@PostConstruct
public void init() {
schedulerFactoryBean = new SchedulerFactoryBean();
schedulerFactoryBean.setQuartzProperties(schedulerProperties);
schedulerFactoryBean.setWaitForJobsToCompleteOnShutdown(getBooleanWithDefault(schedulerProperties.getProperty("scheduler.waitForJobsToCompleteOnShutdown"), true));
schedulerFactoryBean.setApplicationContextSchedulerContextKey("applicationContext");
schedulerFactoryBean.setApplicationContext(applicationContext);
try {
schedulerFactoryBean.afterPropertiesSet();
schedulerFactoryBean.getScheduler().start();
} catch (Exception e) {
throw new SchedulerInstantiationException("Failed to instantiate scheduler with configuration from quartz.properties", e);
}
}
示例13: quartzScheduler
import org.springframework.scheduling.quartz.SchedulerFactoryBean; //导入方法依赖的package包/类
@Bean
public Scheduler quartzScheduler(ApplicationContext context) throws Exception {
SchedulerFactoryBean factory = new SchedulerFactoryBean();
factory.setApplicationContext(context);
factory.setExposeSchedulerInRepository(true);
factory.setApplicationContextSchedulerContextKey(APPLICATION_CONTEXT_KEY);
factory.setJobFactory(glassJobFactory);
Properties properties = new Properties();
properties.setProperty("org.quartz.scheduler.skipUpdateCheck","true");
properties.setProperty("org.quartz.threadPool.class", SimpleThreadPool.class.getName());
properties.setProperty("org.quartz.threadPool.threadCount", "15");
properties.setProperty("org.quartz.threadPool.threadPriority", "4");
if (configuration().isInMemory()) {
properties.setProperty("org.quartz.jobStore.class", RAMJobStore.class.getName());
} else {
factory.setDataSource(dataSource());
properties.setProperty("org.quartz.jobStore.tablePrefix", configuration().getTablePrefix());
properties.setProperty("org.quartz.jobStore.isClustered", "false");
properties.setProperty("org.quartz.jobStore.driverDelegateClass", configuration().getDriverDelegateClass());
}
factory.setQuartzProperties(properties);
factory.afterPropertiesSet();
Scheduler scheduler = factory.getObject();
scheduler.getListenerManager().addJobListener(glassJobListener);
scheduler.getListenerManager().addSchedulerListener(glassSchedulerListener);
scheduler.start();
return scheduler;
}
示例14: autoSchedulerFactory
import org.springframework.scheduling.quartz.SchedulerFactoryBean; //导入方法依赖的package包/类
@Bean(name = QUARTZ_SCHEDULER_FACTORY_BEAN_NAME)
@ConditionalOnMissingBean(name = QUARTZ_SCHEDULER_FACTORY_BEAN_NAME)
public SchedulerFactoryBean autoSchedulerFactory(ApplicationContext applicationContext, JobFactory jobFactory,
QuartzSchedulerProperties properties, @Qualifier(QUARTZ_PROPERTIES_BEAN_NAME) Properties quartzProperties) {
LOGGER.debug("creating SchedulerFactory");
SchedulerFactoryBean factory = BeanUtils.instantiateClass(SchedulerFactoryBean.class);
factory.setApplicationContext(applicationContext);
factory.setJobFactory(jobFactory);
Persistence persistenceSettings = properties.getPersistence();
if (persistenceSettings.isPersisted()) {
factory.setDataSource(getDataSource(applicationContext, persistenceSettings));
if (persistenceSettings.isUsePlatformTxManager()) {
PlatformTransactionManager txManager = getTransactionManager(applicationContext);
if (null != txManager) {
factory.setTransactionManager(txManager);
}
}
}
SchedulerFactory factorySettings = properties.getSchedulerFactory();
factory.setSchedulerName(factorySettings.getSchedulerName());
factory.setPhase(factorySettings.getPhase());
factory.setStartupDelay(factorySettings.getStartupDelay());
factory.setAutoStartup(factorySettings.isAutoStartup());
factory.setWaitForJobsToCompleteOnShutdown(factorySettings.isWaitForJobsToCompleteOnShutdown());
factory.setOverwriteExistingJobs(factorySettings.isOverwriteExistingJobs());
factory.setExposeSchedulerInRepository(factorySettings.isExposeSchedulerInRepository());
factory.setQuartzProperties(quartzProperties);
Collection<Trigger> triggers = getTriggers(applicationContext);
if (null != triggers && !triggers.isEmpty()) {
factory.setTriggers(triggers.toArray(new Trigger[triggers.size()]));
LOGGER.info("staring scheduler factory with " + triggers.size() + " job triggers");
} else {
LOGGER.info("staring scheduler factory with 0 job triggers");
}
QuartzSchedulerFactoryOverrideHook hook = getQuartzSchedulerFactoryOverrideHook(applicationContext);
if (null != hook) {
factory = hook.override(factory, properties, quartzProperties);
}
return factory;
}
开发者ID:andrehertwig,项目名称:spring-boot-starter-quartz,代码行数:50,代码来源:QuartzSchedulerAutoConfiguration.java
示例15: start
import org.springframework.scheduling.quartz.SchedulerFactoryBean; //导入方法依赖的package包/类
public void start() throws Exception {
LOG.info("start crontab");
if (application.getCrontab() != null && application.getCrontab().getCrons() != null) {
Trigger[] triggers = new Trigger[application.getCrontab().getCrons().size()];
for (int i = 0; i < triggers.length; i ++) {
Cron cron = application.getCrontab().getCrons().get(i);
String desc = cron.getDescription();
String exp = cron.getSchedule();
String script = cron.getScript();
MethodInvokingJobDetailFactoryBean jobDetailFactory = new MethodInvokingJobDetailFactoryBean();
jobDetailFactory.setBeanName("jobDetail" + script);
jobDetailFactory.setName("jobDetail" + script);
jobDetailFactory.setTargetObject(this);
jobDetailFactory.setTargetMethod("execute");
jobDetailFactory.setArguments(new Object[]{script, exp, desc});
jobDetailFactory.setConcurrent(application.getCrontab().isConcurrent());
jobDetailFactory.afterPropertiesSet();
JobDetail jobDetail = jobDetailFactory.getObject();
CronTriggerBean trigger = new CronTriggerBean();
trigger.setBeanName("trigger" + script);
trigger.setName("trigger" + script);
trigger.setJobDetail(jobDetail);
trigger.setCronExpression(exp);
trigger.afterPropertiesSet();
triggers[i] = trigger;
}
Properties properties = new Properties();
properties.setProperty("org.quartz.scheduler.skipUpdateCheck", "true");
schedulerFactory = new SchedulerFactoryBean();
schedulerFactory.setBeanName("schedulerFactory");
schedulerFactory.setTriggers(triggers);
schedulerFactory.setQuartzProperties(properties);
//schedulerFactory.setAutoStartup(true);
schedulerFactory.afterPropertiesSet();
schedulerFactory.start();
}
}