当前位置: 首页>>代码示例>>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;未经允许,请勿转载。