當前位置: 首頁>>代碼示例>>Java>>正文


Java ThreadPoolTaskScheduler.initialize方法代碼示例

本文整理匯總了Java中org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler.initialize方法的典型用法代碼示例。如果您正苦於以下問題:Java ThreadPoolTaskScheduler.initialize方法的具體用法?Java ThreadPoolTaskScheduler.initialize怎麽用?Java ThreadPoolTaskScheduler.initialize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler的用法示例。


在下文中一共展示了ThreadPoolTaskScheduler.initialize方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: test

import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; //導入方法依賴的package包/類
@Test
public void test() throws InterruptedException {

  ThreadPoolTaskScheduler executor = new ThreadPoolTaskScheduler();
  executor.initialize();

  NativeSessionCloser closer = mock(NativeSessionCloser.class);
  PingWatchdogManager manager = new PingWatchdogManager(executor, closer);

  manager.setPingWatchdog(true);

  for (int i = 0; i < 10; i++) {
    manager.pingReceived("TransportID", 100);
    Thread.sleep(100);
  }

  Thread.sleep(500);

  verify(closer).closeSession("TransportID");
}
 
開發者ID:Kurento,項目名稱:kurento-java,代碼行數:21,代碼來源:PingWatchdogManagerTest.java

示例2: 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);
    }
}
 
開發者ID:JumpMind,項目名稱:metl,代碼行數:24,代碼來源:AppInitializer.java

示例3: configureTasks

import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; //導入方法依賴的package包/類
@Override
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
    ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler();
    taskScheduler.setPoolSize(50);
    taskScheduler.initialize();
    taskRegistrar.setTaskScheduler(taskScheduler);
}
 
開發者ID:modum-io,項目名稱:tokenapp-backend,代碼行數:8,代碼來源:SchedulingConfigurerConfiguration.java

示例4: 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);
}
 
開發者ID:italia,項目名稱:daf-replicate-ingestion,代碼行數:11,代碼來源:SchedulerConfig.java

示例5: taskScheduler

import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; //導入方法依賴的package包/類
@Test
public void taskScheduler() {
    ThreadPoolTaskScheduler sched = new ThreadPoolTaskScheduler();
    sched.initialize();

    ExecutorServiceMetrics.monitor(registry, sched.getScheduledExecutor(), "sched");
    assertThreadPoolExecutorMetrics("sched");
}
 
開發者ID:micrometer-metrics,項目名稱:micrometer,代碼行數:9,代碼來源:ExecutorServiceMetricsTest.java

示例6: 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;
}
 
開發者ID:FlowCI,項目名稱:flow-platform,代碼行數:13,代碼來源:SchedulerConfig.java

示例7: 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);
}
 
開發者ID:gessnerfl,項目名稱:fake-smtp-server,代碼行數:9,代碼來源:SchedulingConfig.java

示例8: 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);
}
 
開發者ID:ruslanys,項目名稱:vkmusic,代碼行數:10,代碼來源:ExecutorsConfig.java

示例9: getAsyncExecutor

import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; //導入方法依賴的package包/類
@Override
public Executor getAsyncExecutor() {
    ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
    scheduler.setPoolSize(10);
    scheduler.initialize();
    return scheduler;
}
 
開發者ID:borysfan,項目名稱:websocket-poc,代碼行數:8,代碼來源:AyncConfiguration.java

示例10: makeScheduler

import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; //導入方法依賴的package包/類
private TaskScheduler makeScheduler(int poolSize) {
    ThreadPoolTaskScheduler tpts = new ThreadPoolTaskScheduler();
    tpts.setThreadFactory(makeThreadFactory("scheduler"));
    if(poolSize < 1) {
        poolSize = 10;
    }
    tpts.setPoolSize(poolSize);
    tpts.initialize();
    return tpts;
}
 
開發者ID:codeabovelab,項目名稱:haven-platform,代碼行數:11,代碼來源:JobsManagerImpl.java

示例11: createTaskScheduler

import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; //導入方法依賴的package包/類
protected TaskScheduler createTaskScheduler(ShutdownManager shutdownManager) {
    ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler();
    taskScheduler.setPoolSize(threadPoolSize);
    taskScheduler.setThreadNamePrefix("bootique-job-");
    taskScheduler.initialize();

    shutdownManager.addShutdownHook(taskScheduler::shutdown);
    return taskScheduler;
}
 
開發者ID:bootique,項目名稱:bootique-job,代碼行數:10,代碼來源:SchedulerFactory.java

示例12: testLateBindingConsumer

import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; //導入方法依賴的package包/類
@SuppressWarnings("rawtypes")
@Test
public void testLateBindingConsumer() throws Exception {
	BindingServiceProperties properties = new BindingServiceProperties();
	properties.setBindingRetryInterval(1);
	Map<String, BindingProperties> bindingProperties = new HashMap<>();
	BindingProperties props = new BindingProperties();
	props.setDestination("foo");
	final String inputChannelName = "input";
	bindingProperties.put(inputChannelName, props);
	properties.setBindings(bindingProperties);
	DefaultBinderFactory binderFactory = createMockBinderFactory();
	Binder binder = binderFactory.getBinder("mock", MessageChannel.class);
	ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
	scheduler.initialize();
	BindingService service = new BindingService(properties, binderFactory, scheduler);
	MessageChannel inputChannel = new DirectChannel();
	final Binding<MessageChannel> mockBinding = Mockito.mock(Binding.class);
	final CountDownLatch fail = new CountDownLatch(2);
	doAnswer(i -> {
		fail.countDown();
		if (fail.getCount() == 1) {
			throw new RuntimeException("fail");
		}
		return mockBinding;
	}).when(binder).bindConsumer(eq("foo"), isNull(), same(inputChannel), any(ConsumerProperties.class));
	Collection<Binding<MessageChannel>> bindings = service.bindConsumer(inputChannel, inputChannelName);
	assertThat(fail.await(10, TimeUnit.SECONDS)).isTrue();
	assertThat(bindings).hasSize(1);
	Binding<MessageChannel> binding = TestUtils.getPropertyValue(bindings.iterator().next(), "delegate",
			Binding.class);
	assertThat(binding).isSameAs(mockBinding);
	service.unbindConsumers(inputChannelName);
	verify(binder, times(2)).bindConsumer(eq("foo"), isNull(), same(inputChannel),
			any(ConsumerProperties.class));
	verify(binding).unbind();
	binderFactory.destroy();
}
 
開發者ID:spring-cloud,項目名稱:spring-cloud-stream,代碼行數:39,代碼來源:BindingServiceTests.java

示例13: testLateBindingProducer

import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; //導入方法依賴的package包/類
@SuppressWarnings("rawtypes")
@Test
public void testLateBindingProducer() throws Exception {
	BindingServiceProperties properties = new BindingServiceProperties();
	properties.setBindingRetryInterval(1);
	Map<String, BindingProperties> bindingProperties = new HashMap<>();
	BindingProperties props = new BindingProperties();
	props.setDestination("foo");
	final String outputChannelName = "output";
	bindingProperties.put(outputChannelName, props);
	properties.setBindings(bindingProperties);
	DefaultBinderFactory binderFactory = createMockBinderFactory();
	Binder binder = binderFactory.getBinder("mock", MessageChannel.class);
	ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
	scheduler.initialize();
	BindingService service = new BindingService(properties, binderFactory, scheduler);
	MessageChannel outputChannel = new DirectChannel();
	final Binding<MessageChannel> mockBinding = Mockito.mock(Binding.class);
	final CountDownLatch fail = new CountDownLatch(2);
	doAnswer(i -> {
		fail.countDown();
		if (fail.getCount() == 1) {
			throw new RuntimeException("fail");
		}
		return mockBinding;
	}).when(binder).bindProducer(eq("foo"), same(outputChannel), any(ProducerProperties.class));
	Binding<MessageChannel> binding = service.bindProducer(outputChannel, outputChannelName);
	assertThat(fail.await(10, TimeUnit.SECONDS)).isTrue();
	assertThat(binding).isNotNull();
	Binding delegate = TestUtils.getPropertyValue(binding, "delegate", Binding.class);
	assertThat(delegate).isSameAs(mockBinding);
	service.unbindProducers(outputChannelName);
	verify(binder, times(2)).bindProducer(eq("foo"), same(outputChannel), any(ProducerProperties.class));
	verify(delegate).unbind();
	binderFactory.destroy();
	scheduler.destroy();
}
 
開發者ID:spring-cloud,項目名稱:spring-cloud-stream,代碼行數:38,代碼來源:BindingServiceTests.java

示例14: taskScheduler

import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; //導入方法依賴的package包/類
@Bean(destroyMethod = "shutdown")
public TaskScheduler taskScheduler() {
	ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
	scheduler.setErrorHandler(new ErrorHandler() {
		@Override
		public void handleError(Throwable t) {
			LogManager.getLogger().error("error while handling job", t);
		}
	});
	scheduler.initialize();
	return scheduler;
}
 
開發者ID:digitalfondue,項目名稱:lavagna,代碼行數:13,代碼來源:PersistenceAndServiceConfig.java

示例15: start

import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; //導入方法依賴的package包/類
@PostConstruct
public void start() {
	Validate.notBlank(cronExpression);

	threadPoolTaskScheduler = new ThreadPoolTaskScheduler();
	threadPoolTaskScheduler.setThreadNamePrefix("SpringCronJob");
	threadPoolTaskScheduler.initialize();

	threadPoolTaskScheduler.schedule(this, new CronTrigger(cronExpression));
}
 
開發者ID:Michaelleolee,項目名稱:appengine,代碼行數:11,代碼來源:SpringCronJob.java


注:本文中的org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler.initialize方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。