Java Code Examples for org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler#setDaemon()

The following examples show how to use org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler#setDaemon() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StackdriverTraceAutoConfiguration.java    From spring-cloud-gcp with Apache License 2.0 6 votes vote down vote up
@Bean
@ConditionalOnMissingBean(name = "traceExecutorProvider")
public ExecutorProvider traceExecutorProvider(GcpTraceProperties traceProperties, @Qualifier("traceSenderThreadPool") Optional<ThreadPoolTaskScheduler> userProvidedScheduler) {
	ThreadPoolTaskScheduler scheduler;
	if (userProvidedScheduler.isPresent()) {
		scheduler = userProvidedScheduler.get();
	}
	else {
		this.defaultTraceSenderThreadPool = new ThreadPoolTaskScheduler();
		scheduler = this.defaultTraceSenderThreadPool;
		scheduler.setPoolSize(traceProperties.getNumExecutorThreads());
		scheduler.setThreadNamePrefix("gcp-trace-sender");
		scheduler.setDaemon(true);
		scheduler.initialize();
	}
	return FixedExecutorProvider.create(scheduler.getScheduledExecutor());
}
 
Example 2
Source File: SecretLeaseContainer.java    From spring-vault with Apache License 2.0 6 votes vote down vote up
@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 : this.requestedSecrets) {
			this.renewals.put(requestedSecret, new LeaseRenewalScheduler(this.taskScheduler));
		}
	}
}
 
Example 3
Source File: VaultBootstrapConfiguration.java    From spring-cloud-vault with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a new {@link TaskSchedulerWrapper} that encapsulates a bean implementing
 * {@link TaskScheduler} and {@link AsyncTaskExecutor}.
 * @return the {@link TaskSchedulerWrapper} bean.
 * @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
	this.applicationContext.registerShutdownHook();

	return new TaskSchedulerWrapper(threadPoolTaskScheduler);
}
 
Example 4
Source File: TaskSchedulerConfig.java    From seppb with MIT License 5 votes vote down vote up
@Bean
public TaskScheduler taskScheduler() {
    ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
    scheduler.setPoolSize(6);
    scheduler.setThreadNamePrefix("scheduled-task-");
    scheduler.setDaemon(true);
    return scheduler;
}
 
Example 5
Source File: DatabaseMySQLTraceLogFlushHandler.java    From summerframework with Apache License 2.0 5 votes vote down vote up
public DatabaseMySQLTraceLogFlushHandler(DataSource dataSource) {
    Assert.notNull(dataSource, "DatabaseTraceLogFlushHandler must have dataSource.");
    this.dataSource = dataSource;
    doWithConnection(createTableIfNotExist);
    tableReady = true;
    threadPoolTaskScheduler = new ThreadPoolTaskScheduler();
    threadPoolTaskScheduler.setDaemon(true);
    threadPoolTaskScheduler.setThreadNamePrefix("TraceLogFlush");
    threadPoolTaskScheduler.initialize();
    threadPoolTaskScheduler.schedule(cleanerTask,
        new CronTrigger(System.getProperty("rabbit.trace.flush.trigger", "0 0 1 * * ?")));
}
 
Example 6
Source File: GcpPubSubAutoConfiguration.java    From spring-cloud-gcp with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnMissingBean(name = "pubsubPublisherThreadPool")
public ThreadPoolTaskScheduler pubsubPublisherThreadPool() {
	ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
	scheduler.setPoolSize(this.gcpPubSubProperties.getPublisher().getExecutorThreads());
	scheduler.setThreadNamePrefix("gcp-pubsub-publisher");
	scheduler.setDaemon(true);
	return scheduler;
}
 
Example 7
Source File: GcpPubSubAutoConfiguration.java    From spring-cloud-gcp with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnMissingBean(name = "pubsubSubscriberThreadPool")
public ThreadPoolTaskScheduler pubsubSubscriberThreadPool() {
	ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
	scheduler.setPoolSize(this.gcpPubSubProperties.getSubscriber().getExecutorThreads());
	scheduler.setThreadNamePrefix("gcp-pubsub-subscriber");
	scheduler.setDaemon(true);
	return scheduler;
}
 
Example 8
Source File: WebRestApiApplication.java    From metasfresh-webui-api-legacy with GNU General Public License v3.0 5 votes vote down vote up
@Bean(BEANNAME_WebuiTaskScheduler)
public TaskScheduler webuiTaskScheduler()
{
	final ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler();
	taskScheduler.setThreadNamePrefix("webui-task-scheduler-");
	taskScheduler.setDaemon(true);
	taskScheduler.setPoolSize(10);
	return taskScheduler;
}
 
Example 9
Source File: SchedulingConfig.java    From NettyReverseProxy with Apache License 2.0 5 votes vote down vote up
@Bean(name = "taskScheduler")
public ThreadPoolTaskScheduler taskScheduler() {
    ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
    scheduler.setPoolSize(10);
    scheduler.setDaemon(true);
    scheduler.setThreadNamePrefix("taskScheduler-");
    return scheduler;
}
 
Example 10
Source File: DIConfiguration.java    From waltz with Apache License 2.0 4 votes vote down vote up
@Bean
public TaskScheduler taskScheduler() {
    ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
    scheduler.setDaemon(true);
    return scheduler;
}