Spring Framework ThreadPoolTaskScheduler - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Spring Framework ThreadPoolTaskScheduler class.

This code example shows how to use the following methods:setPoolSize, setRemoveOnCancelPolicy, setThreadNamePrefix
 */ 
public class WebSocketConfigurationSupport {
 
	@Bean 
	public HandlerMapping webSocketHandlerMapping() {
		ServletWebSocketHandlerRegistry registry = new ServletWebSocketHandlerRegistry(defaultSockJsTaskScheduler());
		registerWebSocketHandlers(registry);
		return registry.getHandlerMapping();
	} 
 
	protected void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
	} 
 
	/** 
	 * The default TaskScheduler to use if none is configured via 
	 * {@link SockJsServiceRegistration#setTaskScheduler}, i.e. 
	 * <pre class="code"> 
	 * &#064;Configuration 
	 * &#064;EnableWebSocket 
	 * public class WebSocketConfig implements WebSocketConfigurer { 

8
CodeRank
This code example shows how to use the following methods:schedule, initialize, setThreadNamePrefix
This code example shows how to use the following methods:
 
	private int streamBytesLimit = 128 * 1024; 
 
	private long heartbeatTime = 25 * 1000; 
 
	private TaskScheduler taskScheduler = new ThreadPoolTaskScheduler(); 
 
	private SockJsMessageCodec messageCodec = new Jackson2SockJsMessageCodec(); 
 
	private int httpMessageCacheSize = 100; 
 
 
	@Override 
	public int getStreamBytesLimit() { 
		return this.streamBytesLimit; 
	} 
 
	public void setStreamBytesLimit(int streamBytesLimit) { 
		this.streamBytesLimit = streamBytesLimit; 
	} 
6
CodeRank
This code example shows how to use the following methods:
 
	@Override 
	@Before 
	public void setUp() { 
		super.setUp(); 
		this.service = new TestSockJsService(new ThreadPoolTaskScheduler()); 
	} 
 
 
	@Test 
	public void validateRequest() throws Exception { 
 
		this.service.setWebSocketEnabled(false); 
		resetResponseAndHandleRequest("GET", "/echo/server/session/websocket", HttpStatus.NOT_FOUND); 
 
		this.service.setWebSocketEnabled(true); 
		resetResponseAndHandleRequest("GET", "/echo/server/session/websocket", HttpStatus.OK); 
 
		resetResponseAndHandleRequest("GET", "/echo//", HttpStatus.NOT_FOUND); 
		resetResponseAndHandleRequest("GET", "/echo///", HttpStatus.NOT_FOUND); 
6
CodeRank
This code example shows how to use the following methods:setThreadNamePrefix
    private GameHandler gameHandler;
 
    @Bean 
    public SimpleUrlHandlerMapping handlerMapping() {
 
        SockJsService sockJsService = new DefaultSockJsService(taskScheduler());
 
        Map<String, Object> urlMap = new HashMap<String, Object>();
        urlMap.put("/game/websocket/**", new SockJsHttpRequestHandler(sockJsService, gameHandler));
 
        SimpleUrlHandlerMapping hm = new SimpleUrlHandlerMapping();
        hm.setUrlMap(urlMap);
        return hm;
    } 
 
    @Bean 
    public ThreadPoolTaskScheduler taskScheduler() {
      ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler();
      taskScheduler.setThreadNamePrefix("SockJS-");
      return taskScheduler;

5
CodeRank
This code example shows how to use the following methods:scheduleAtFixedRate, initialize
    @Lazy 
    private StreamingFailoverService streamingFailoverService;
 
    @Bean 
    public TaskScheduler taskScheduler() {
        ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler();
        taskScheduler.initialize();
        if (configurationContext.isFailOverEnabled()) {
            taskScheduler.scheduleAtFixedRate(failOverTask(), configurationContext.getFailOverPeriod());
        } 
        return taskScheduler;
    } 
 
    public FailOverTask failOverTask() { 
        return new FailOverTask(streamingFailoverService);
    } 
} 
5
CodeRank
This code example shows how to use the following methods:
    private static final long serialVersionUID = 1L;
    private final CamelContext camelContext;
    private final Object source;
    private final String name;
 
    public CamelThreadPoolTaskScheduler(CamelContext camelContext, Object source, String name) {
        this.camelContext = camelContext;
        this.source = source;
        this.name = name;
    } 
 
    @Override 
    protected ScheduledExecutorService createExecutor(int poolSize, ThreadFactory threadFactory, RejectedExecutionHandler rejectedExecutionHandler) {
        return camelContext.getExecutorServiceManager().newScheduledThreadPool(source, name, poolSize);
    } 
 
    @Override 
    public void shutdown() { 
        camelContext.getExecutorServiceManager().shutdownNow(getScheduledExecutor());
    } 
5
CodeRank
This code example shows how to use the following methods:setPoolSize, initialize
public class DefaultQualityAnalyzerScheduler implements QualityAnalyzerScheduler { 
 
  // TODO make this configurable 
  private static final int DEFAULT_POOL_SIZE = 10;
 
  private final ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
 
  private final ProjectRepository projectRepository;
  private final ViolationsCalculatorService violationsCalculatorService;
  private final ScmAvailabilityCheckerServiceFactory scmAvailabilityCheckerServiceFactory;
  private final CodeChangeProbabilityCalculatorFactory codeChangeProbabilityCalculatorFactory;
  private final SecureChangeProbabilityCalculator secureChangeProbabilityCalculator;
  private final QualityViolationCostsCalculator costsCalculator;
  private final QualityAnalysisRepository qualityAnalysisRepository;
 
  private final Set<Project> alreadyScheduledProjects = Sets.newCopyOnWriteArraySet();
 
  @Autowired 
  public DefaultQualityAnalyzerScheduler(ProjectRepository projectRepository,
                                         ViolationsCalculatorService violationsCalculatorService,

5
CodeRank
This code example shows how to use the following methods:getScheduledExecutor
        // we start the scheduler in doStart 
    } 
 
    @Override 
    public boolean isSchedulerStarted() { 
        return taskScheduler != null && !taskScheduler.getScheduledExecutor().isShutdown();
    } 
 
    @Override 
    public void setCamelContext(CamelContext camelContext) {
        this.camelContext = camelContext;
    } 
 
    @Override 
    public CamelContext getCamelContext() { 
        return camelContext;
    } 
 
    public String getCron() {
        return cron;
5
CodeRank
This code example shows how to use the following methods:setPoolSize, initialize
		adapter.setOutputChannel(channel);
		adapter.setBeanFactory(mock(BeanFactory.class));
		adapter.afterPropertiesSet();
		assertTrue(latch1.await(10, TimeUnit.SECONDS));
		adapter.setRetryInterval(10000);
		ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler();
		taskScheduler.setPoolSize(1);
		taskScheduler.initialize();
		adapter.setTaskScheduler(taskScheduler);
		adapter.start();
		Message<?> message = channel.receive(10000);
		assertNotNull(message); 
		assertEquals("Test1", new String((byte[]) message.getPayload()));
		message = channel.receive(10000);
		assertNotNull(message); 
		assertEquals("Test2", new String((byte[]) message.getPayload()));
		adapter.stop();
		adapter.start();
		adapter.stop();
		latch2.countDown();
5
CodeRank
See Code Examples for Spring Framework ThreadPoolTaskScheduler Methods: