当前位置: 首页>>代码示例>>Java>>正文


Java ConcurrentTaskScheduler类代码示例

本文整理汇总了Java中org.springframework.scheduling.concurrent.ConcurrentTaskScheduler的典型用法代码示例。如果您正苦于以下问题:Java ConcurrentTaskScheduler类的具体用法?Java ConcurrentTaskScheduler怎么用?Java ConcurrentTaskScheduler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ConcurrentTaskScheduler类属于org.springframework.scheduling.concurrent包,在下文中一共展示了ConcurrentTaskScheduler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import org.springframework.scheduling.concurrent.ConcurrentTaskScheduler; //导入依赖的package包/类
public static void main(String... argv) {
    WebSocketClient webSocketClient = new StandardWebSocketClient();
    WebSocketStompClient stompClient = new WebSocketStompClient(webSocketClient);
    stompClient.setMessageConverter(new MappingJackson2MessageConverter());
    stompClient.setTaskScheduler(new ConcurrentTaskScheduler());

    String url = "ws://127.0.0.1:8080/hello";
    StompSessionHandler sessionHandler = new MySessionHandler();
    stompClient.connect(url, sessionHandler);

    new Scanner(System.in).nextLine(); //Don't close immediately.
}
 
开发者ID:nielsutrecht,项目名称:spring-boot-websocket-client,代码行数:13,代码来源:ServiceClient.java

示例2: configureTasks

import org.springframework.scheduling.concurrent.ConcurrentTaskScheduler; //导入依赖的package包/类
@Override
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
    if (properties.isEnabled()) {
        TaskScheduler taskScheduler = null;
        try {
            taskScheduler = this.beanFactory.getBean(TaskScheduler.class);
        } catch (NoUniqueBeanDefinitionException e) {
            taskScheduler = this.beanFactory.getBean("taskScheduler", TaskScheduler.class);
        } catch (NoSuchBeanDefinitionException ex) {
            log.warn("'useExistingScheduler' was configured to 'true', but we did not find any bean.");
        }
        if (taskScheduler != null) {
            log.info("register existing TaskScheduler");
            taskRegistrar.setScheduler(taskScheduler);
        } else {
            throw new BeanCreationException("Expecting a 'ConcurrentTaskScheduler' injected, but was 'null'");
        }
    } else {
        log.info("'CustomSchedulingConfiguration' is disabled, create a default - 'ConcurrentTaskScheduler'");
        this.localExecutor = Executors.newSingleThreadScheduledExecutor();
        taskRegistrar.setScheduler(new ConcurrentTaskScheduler(localExecutor));
    }
}
 
开发者ID:zalando-stups,项目名称:booties,代码行数:24,代码来源:CustomSchedulingConfiguration.java

示例3: doTestWrapperTokenCreated

import org.springframework.scheduling.concurrent.ConcurrentTaskScheduler; //导入依赖的package包/类
private void doTestWrapperTokenCreated(String authMountPath) {
    final ClientHttpRequestFactory factory = createClientHttpRequestFactory();
    final VaultTemplate template = new VaultTemplate(getVault().getEndpoint(), factory, () -> VaultToken.of(getVault().getToken()));

    // Ensure approle auth enabled
    template.opsForSys().authMount(authMountPath, VaultMount.create("approle"));
    then(template.opsForSys().getAuthMounts()).containsKey(authMountPath + "/");
    template.write("auth/" + authMountPath + "/role/testrole", CollectionsUtil.asMap(
            "secret_id_ttl", "10m",
            "token_num_uses", "10",
            "token_ttl", "20m",
            "token_max_ttl", "30m",
            "secret_id_num_uses", "40"
    ));
    Pair<String, String> credentials = getAppRoleCredentials(template, "auth/" + authMountPath + "/role/testrole");


    final Pair<String, String> wrapped = VaultConnector.doRequestWrappedToken(new VaultFeatureSettings(getVault().getUrl(), authMountPath, credentials.getFirst(), credentials.getSecond()));

    then(wrapped.getFirst()).isNotNull();
    then(wrapped.getSecond()).isNotNull();


    final CubbyholeAuthenticationOptions options = CubbyholeAuthenticationOptions.builder()
            .wrapped()
            .initialToken(VaultToken.of(wrapped.getFirst()))
            .build();
    final RestTemplate simpleTemplate = UtilKt.createRestTemplate(new VaultFeatureSettings(getVault().getUrl(), authMountPath, "", ""));
    final CubbyholeAuthentication authentication = new CubbyholeAuthentication(options, simpleTemplate);
    final TaskScheduler scheduler = new ConcurrentTaskScheduler();

    final MyLifecycleAwareSessionManager sessionManager = new MyLifecycleAwareSessionManager(authentication, simpleTemplate, scheduler);

    then(sessionManager.getSessionToken()).isNotNull();

    sessionManager.renewToken();

    then(sessionManager.getSessionToken()).isNotNull();
}
 
开发者ID:JetBrains,项目名称:teamcity-hashicorp-vault-plugin,代码行数:40,代码来源:VaultConnectorTest.java

示例4: setScheduler

import org.springframework.scheduling.concurrent.ConcurrentTaskScheduler; //导入依赖的package包/类
/**
 * Set the {@link TaskScheduler} to register scheduled tasks with, or a
 * {@link java.util.concurrent.ScheduledExecutorService} to be wrapped as a
 * {@code TaskScheduler}.
 */
public void setScheduler(Object scheduler) {
	Assert.notNull(scheduler, "Scheduler object must not be null");
	if (scheduler instanceof TaskScheduler) {
		this.taskScheduler = (TaskScheduler) scheduler;
	}
	else if (scheduler instanceof ScheduledExecutorService) {
		this.taskScheduler = new ConcurrentTaskScheduler(((ScheduledExecutorService) scheduler));
	}
	else {
		throw new IllegalArgumentException("Unsupported scheduler type: " + scheduler.getClass());
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:18,代码来源:ScheduledTaskRegistrar.java

示例5: testReconnectDetailsSetServerAvailableAtStartup

import org.springframework.scheduling.concurrent.ConcurrentTaskScheduler; //导入依赖的package包/类
@Test
public void testReconnectDetailsSetServerAvailableAtStartup()
    throws MqttException, InterruptedException
{
    StaticApplicationContext applicationContext = getStaticApplicationContext();
    TaskScheduler taskScheduler = new ConcurrentTaskScheduler();
    MessageChannel inboundMessageChannel = new ExecutorSubscribableChannel();
    PahoAsyncMqttClientService service = new PahoAsyncMqttClientService(
        BrokerHelper.getProxyUri(), BrokerHelper.getClientId(), MqttClientConnectionType.PUBSUB,
        null);
    service.setApplicationEventPublisher(applicationContext);
    service.setInboundMessageChannel(inboundMessageChannel);
    service.subscribe(String.format("client/%s", BrokerHelper.getClientId()),
        MqttQualityOfService.QOS_0);
    service.getMqttConnectOptions().setCleanSession(true);
    service.setReconnectDetails(new DefaultReconnectService(), taskScheduler);
    Assert.assertTrue(service.start());
    Assert.assertTrue(service.isConnected());
    Assert.assertTrue(service.isStarted());
    // simulate a lost connection
    CRUSHER_PROXY.reopen();
    Assert.assertFalse(service.isStarted());
    Assert.assertFalse(service.isConnected());
    Thread.sleep(1100);
    Assert.assertTrue(service.isStarted());
    Assert.assertTrue(service.isConnected());
    Assert.assertEquals(2, clientConnectedCount.get());
    Assert.assertEquals(0, clientDisconnectedCount.get());
    Assert.assertEquals(1, clientLostConnectionCount.get());
    Assert.assertEquals(0, clientFailedConnectionCount.get());
    service.stop();
    service.close();
    applicationContext.close();
}
 
开发者ID:christophersmith,项目名称:summer-mqtt,代码行数:35,代码来源:AutomaticReconnectTest.java

示例6: testReconnectDetailsSetServerUnavailableAtStartup

import org.springframework.scheduling.concurrent.ConcurrentTaskScheduler; //导入依赖的package包/类
@Test
public void testReconnectDetailsSetServerUnavailableAtStartup()
    throws MqttException, InterruptedException
{
    StaticApplicationContext applicationContext = getStaticApplicationContext();
    CRUSHER_PROXY.close();
    TaskScheduler taskScheduler = new ConcurrentTaskScheduler();
    MessageChannel inboundMessageChannel = new ExecutorSubscribableChannel();
    PahoAsyncMqttClientService service = new PahoAsyncMqttClientService(
        BrokerHelper.getProxyUri(), BrokerHelper.getClientId(), MqttClientConnectionType.PUBSUB,
        null);
    service.setApplicationEventPublisher(applicationContext);
    service.setInboundMessageChannel(inboundMessageChannel);
    service.subscribe(String.format("client/%s", BrokerHelper.getClientId()),
        MqttQualityOfService.QOS_0);
    service.getMqttConnectOptions().setCleanSession(true);
    service.setReconnectDetails(new DefaultReconnectService(), taskScheduler);
    Assert.assertFalse(service.start());
    Assert.assertFalse(service.isConnected());
    Assert.assertFalse(service.isStarted());
    CRUSHER_PROXY.open();
    Thread.sleep(3100);
    Assert.assertTrue(service.isConnected());
    Assert.assertTrue(service.isStarted());
    Assert.assertEquals(1, clientConnectedCount.get());
    Assert.assertEquals(0, clientDisconnectedCount.get());
    Assert.assertEquals(0, clientLostConnectionCount.get());
    Assert.assertEquals(1, clientFailedConnectionCount.get());
    service.stop();
    service.close();
    applicationContext.close();
}
 
开发者ID:christophersmith,项目名称:summer-mqtt,代码行数:33,代码来源:AutomaticReconnectTest.java

示例7: taskScheduler

import org.springframework.scheduling.concurrent.ConcurrentTaskScheduler; //导入依赖的package包/类
@Bean(name = DEFAULT_TASK_SCHEDULER_BEAN_NAME)
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public TaskScheduler taskScheduler() {
    if (taskExecutor != null) {
        log.debug("create task-scheduler with pre-configured executor ...");
        return new ConcurrentTaskScheduler(taskExecutor, scheduledExecutorService());
    } else {
        log.debug("create task-scheduler without pre-configured executor ...");
        return new ConcurrentTaskScheduler(scheduledExecutorService());
    }
}
 
开发者ID:zalando-stups,项目名称:booties,代码行数:12,代码来源:CustomSchedulingConfiguration.java

示例8: taskScheduler

import org.springframework.scheduling.concurrent.ConcurrentTaskScheduler; //导入依赖的package包/类
@Bean(name="hapiJpaTaskExecutor")
public AsyncTaskExecutor taskScheduler() {
	ConcurrentTaskScheduler retVal = new ConcurrentTaskScheduler();
	retVal.setConcurrentExecutor(scheduledExecutorService().getObject());
	retVal.setScheduledExecutor(scheduledExecutorService().getObject());
	return retVal;
}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:8,代码来源:FhirAutoConfiguration.java

示例9: taskScheduler

import org.springframework.scheduling.concurrent.ConcurrentTaskScheduler; //导入依赖的package包/类
@Bean(name=TASK_EXECUTOR_NAME)
public TaskScheduler taskScheduler() {
	ConcurrentTaskScheduler retVal = new ConcurrentTaskScheduler();
	retVal.setConcurrentExecutor(scheduledExecutorService().getObject());
	retVal.setScheduledExecutor(scheduledExecutorService().getObject());
	return retVal;
}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:8,代码来源:BaseConfig.java

示例10: CronChangeFinder

import org.springframework.scheduling.concurrent.ConcurrentTaskScheduler; //导入依赖的package包/类
public CronChangeFinder() {
    this.currentCron = getCronFromDB();
    this.scheduler = new ConcurrentTaskScheduler();
    this.task = new BizRunnable(this);

    this.futrue = this.scheduler.schedule(this.task, new CronTrigger(this.currentCron));
}
 
开发者ID:haogrgr,项目名称:haogrgr-test,代码行数:8,代码来源:DynamicCronExp.java

示例11: main

import org.springframework.scheduling.concurrent.ConcurrentTaskScheduler; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
	ConcurrentTaskScheduler scheduler =  new ConcurrentTaskScheduler();
	scheduler.schedule(new Runnable() {
		@Override
		public void run() {
			System.out.println("test");
		}
	}, new CronTrigger("0/1 * * * * ?"));//3秒一次
	
	System.in.read();
}
 
开发者ID:haogrgr,项目名称:haogrgr-test,代码行数:12,代码来源:SpringCronScheduler.java

示例12: taskScheduler

import org.springframework.scheduling.concurrent.ConcurrentTaskScheduler; //导入依赖的package包/类
@Bean
TaskScheduler taskScheduler() {
    return new ConcurrentTaskScheduler(threadPool());
}
 
开发者ID:eclipse,项目名称:hawkbit-examples,代码行数:5,代码来源:DeviceSimulator.java

示例13: withExecutorService

import org.springframework.scheduling.concurrent.ConcurrentTaskScheduler; //导入依赖的package包/类
@Override
public ScheduledLockConfigurationBuilderWithoutDefaultLockAtMostFor withExecutorService(ScheduledExecutorService scheduledExecutorService) {
    this.taskScheduler = new ConcurrentTaskScheduler(scheduledExecutorService);
    return this;
}
 
开发者ID:lukas-krecan,项目名称:ShedLock,代码行数:6,代码来源:DefaultScheduledLockConfigurationBuilder.java

示例14: taskScheduler

import org.springframework.scheduling.concurrent.ConcurrentTaskScheduler; //导入依赖的package包/类
@Bean(name = DEFAULT_TASK_SCHEDULER_BEAN_NAME)
@ConditionalOnMissingBean(name = DEFAULT_TASK_SCHEDULER_BEAN_NAME)
public TaskScheduler taskScheduler(final ScheduledExecutorService taskSchedulerService, final Tracer tracer) {
    return new ConcurrentTaskScheduler(manage(taskSchedulerService, tracer));
}
 
开发者ID:zalando,项目名称:tracer,代码行数:6,代码来源:TracerAutoConfiguration.java

示例15: taskScheduler

import org.springframework.scheduling.concurrent.ConcurrentTaskScheduler; //导入依赖的package包/类
/**
 * @return {@link TaskScheduler} for task execution
 */
@Bean
@ConditionalOnMissingBean
public TaskScheduler taskScheduler() {
    return new ConcurrentTaskScheduler(scheduledExecutorService());
}
 
开发者ID:eclipse,项目名称:hawkbit,代码行数:9,代码来源:ExecutorAutoConfiguration.java


注:本文中的org.springframework.scheduling.concurrent.ConcurrentTaskScheduler类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。