本文整理汇总了Java中org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler.setThreadNamePrefix方法的典型用法代码示例。如果您正苦于以下问题:Java ThreadPoolTaskScheduler.setThreadNamePrefix方法的具体用法?Java ThreadPoolTaskScheduler.setThreadNamePrefix怎么用?Java ThreadPoolTaskScheduler.setThreadNamePrefix使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler
的用法示例。
在下文中一共展示了ThreadPoolTaskScheduler.setThreadNamePrefix方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: taskScheduler
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; //导入方法依赖的package包/类
@Bean
public ThreadPoolTaskScheduler taskScheduler()
{
logger.info("Setting up thread pool task scheduler with 20 threads.");
ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
scheduler.setPoolSize(20);
scheduler.setThreadNamePrefix("task-");
scheduler.setAwaitTerminationSeconds(60);
scheduler.setWaitForTasksToCompleteOnShutdown(true);
scheduler.setErrorHandler(t -> schedulingLogger.error(
"Unknown error occurred while executing task.", t
));
scheduler.setRejectedExecutionHandler(
(r, e) -> schedulingLogger.error(
"Execution of task {} was rejected for unknown reasons.", r
)
);
return scheduler;
}
示例2: bbTaskScheduler
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; //导入方法依赖的package包/类
@Bean
public TaskScheduler bbTaskScheduler() {
ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler();
taskScheduler.setThreadNamePrefix("API-Schd-ThrP-");
taskScheduler.setAwaitTerminationSeconds(1);
taskScheduler.setRejectedExecutionHandler(new ThreadPoolTaskRejectedHandler());
return taskScheduler;
}
示例3: taskScheduler
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; //导入方法依赖的package包/类
@Bean
public ThreadPoolTaskScheduler taskScheduler() {
String levelString = context.getInitParameter("threadNumber");
if (levelString == null) {
levelString = "4";
}
int level = Integer.parseInt(levelString);
log.info("Creating thread pool with " + level + " threads");
ThreadPoolTaskScheduler exec = new ThreadPoolTaskScheduler();
exec.setPoolSize(level);
exec.setThreadNamePrefix("transaction");
exec.setAwaitTerminationSeconds(60);
exec.setWaitForTasksToCompleteOnShutdown(true);
exec.setRejectedExecutionHandler(new RejectedExecutionHandler() {
@Override
public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
StringBuilder errorBuilder = new StringBuilder("Task Rejected");
log.error(errorBuilder.toString());
}
});
return exec;
}
示例4: vaultTaskScheduler
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; //导入方法依赖的package包/类
/**
* Creates a new {@link TaskSchedulerWrapper} that encapsulates a bean implementing
* {@link TaskScheduler} and {@link AsyncTaskExecutor}.
*
* @return
* @see ThreadPoolTaskScheduler
*/
@Bean
@Lazy
@ConditionalOnMissingBean(TaskSchedulerWrapper.class)
public TaskSchedulerWrapper vaultTaskScheduler() {
ThreadPoolTaskScheduler threadPoolTaskScheduler = new ThreadPoolTaskScheduler();
threadPoolTaskScheduler.setPoolSize(2);
threadPoolTaskScheduler.setDaemon(true);
threadPoolTaskScheduler.setThreadNamePrefix("Spring-Cloud-Vault-");
// This is to destroy bootstrap resources
// otherwise, the bootstrap context is not shut down cleanly
applicationContext.registerShutdownHook();
return new TaskSchedulerWrapper(threadPoolTaskScheduler);
}
示例5: initBackgroundJobs
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; //导入方法依赖的package包/类
protected void initBackgroundJobs(WebApplicationContext ctx) {
try {
IConfigurationService configurationService = ctx.getBean(IConfigurationService.class);
IImportExportService importExportService = ctx.getBean(IImportExportService.class);
IOperationsService operationsService = ctx.getBean(IOperationsService.class);
jobScheduler = new ThreadPoolTaskScheduler();
jobScheduler.setDaemon(true);
jobScheduler.setThreadNamePrefix("background-job-");
jobScheduler.setPoolSize(2);
jobScheduler.initialize();
TypedProperties properties = operationsService.findGlobalSetttingsAsProperties();
if (properties.is(CONFIG_BACKUP_ENABLED, DEFAULT_CONFIG_BACKUP_ENABLED)) {
jobScheduler.schedule(new BackupJob(importExportService, configurationService, operationsService, getConfigDir(false)),
new CronTrigger(
properties.get(CONFIG_BACKUP_CRON, DEFAULT_CONFIG_BACKUP_CRON)));
}
jobScheduler.scheduleAtFixedRate(() -> configurationService.doInBackground(), 600000);
} catch (Exception e) {
LoggerFactory.getLogger(getClass()).info("Failed to schedule the backup job", e);
}
}
示例6: afterPropertiesSet
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; //导入方法依赖的package包/类
@Override
public void afterPropertiesSet() throws Exception {
if (!this.initialized) {
super.afterPropertiesSet();
this.initialized = true;
if (this.taskScheduler == null) {
ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
scheduler.setDaemon(true);
scheduler.setThreadNamePrefix(String.format("%s-%d-", getClass()
.getSimpleName(), poolId.incrementAndGet()));
scheduler.afterPropertiesSet();
this.taskScheduler = scheduler;
this.manageTaskScheduler = true;
}
for (RequestedSecret requestedSecret : requestedSecrets) {
this.renewals.put(requestedSecret, new LeaseRenewalScheduler(
this.taskScheduler));
}
}
}
示例7: taskScheduler
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; //导入方法依赖的package包/类
@Bean()
public ThreadPoolTaskScheduler taskScheduler() {
ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
scheduler.setPoolSize(100);
scheduler.setThreadNamePrefix("Scheduler-");
scheduler.setWaitForTasksToCompleteOnShutdown(true);
scheduler.setRemoveOnCancelPolicy(true);
return scheduler;
}
示例8: configureTasks
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; //导入方法依赖的package包/类
@Override
public void configureTasks(ScheduledTaskRegistrar scheduledTaskRegistrar) {
ThreadPoolTaskScheduler threadPoolTaskScheduler = new ThreadPoolTaskScheduler();
threadPoolTaskScheduler.setPoolSize(POOL_SIZE);
threadPoolTaskScheduler.setThreadNamePrefix("SchedulerThreads-");
threadPoolTaskScheduler.initialize();
scheduledTaskRegistrar.setTaskScheduler(threadPoolTaskScheduler);
}
示例9: taskScheduler
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; //导入方法依赖的package包/类
@Bean
public TaskScheduler taskScheduler () {
ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
scheduler.setThreadNamePrefix( CsapCoreService.class.getSimpleName() + "Scheduler" );
scheduler.setPoolSize( 2 );
return scheduler;
}
示例10: taskSchedulerExecutor
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; //导入方法依赖的package包/类
@Bean(name = "taskSchedulerExecutor")
public ThreadPoolTaskScheduler taskSchedulerExecutor() {
ThreadPoolTaskScheduler threadPool = new ThreadPoolTaskScheduler();
threadPool.setPoolSize(80);
threadPool.setRejectedExecutionHandler(new RejectExecutionImpl());
threadPool.setThreadNamePrefix("Scheduler-");
threadPool.setThreadGroupName("Scheduler");
return threadPool;
}
示例11: schedulerTaskExecutor
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; //导入方法依赖的package包/类
/**
* Thread pool for spring scheduling
*/
@Bean(destroyMethod = "shutdown")
public ThreadPoolTaskScheduler schedulerTaskExecutor() {
ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
scheduler.setPoolSize(DEFAULT_SCHEDULER_POOL_SIZE);
scheduler.setDaemon(true);
scheduler.setThreadNamePrefix("api-task-");
scheduler.initialize();
return scheduler;
}
示例12: taskScheduler
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; //导入方法依赖的package包/类
@Bean(destroyMethod = "shutdown")
public ThreadPoolTaskScheduler taskScheduler() {
ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
scheduler.setPoolSize(20);
scheduler.setThreadNamePrefix("task-");
scheduler.setAwaitTerminationSeconds(60);
scheduler.setWaitForTasksToCompleteOnShutdown(true);
return scheduler;
}
示例13: configureTasks
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; //导入方法依赖的package包/类
@Override
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler();
taskScheduler.setThreadNamePrefix("task-pool");
taskScheduler.setPoolSize(10);
taskScheduler.initialize();
taskRegistrar.setTaskScheduler(taskScheduler);
}
示例14: configureTasks
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; //导入方法依赖的package包/类
@Override
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler();
taskScheduler.setPoolSize(5);
taskScheduler.initialize();
taskScheduler.setThreadNamePrefix("ScheduledExecutor-");
taskRegistrar.setTaskScheduler(taskScheduler);
}
示例15: messageBrokerTaskScheduler
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; //导入方法依赖的package包/类
@Bean(name={"messageBrokerTaskScheduler", "messageBrokerSockJsTaskScheduler"})
public ThreadPoolTaskScheduler messageBrokerTaskScheduler() {
ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
scheduler.setThreadNamePrefix("MessageBroker-");
scheduler.setPoolSize(Runtime.getRuntime().availableProcessors());
scheduler.setRemoveOnCancelPolicy(true);
return scheduler;
}