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

The following examples show how to use org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler#afterPropertiesSet() . 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: ReactorNettyTcpStompClientTests.java    From spring-analysis-note with MIT License 7 votes vote down vote up
@Before
public void setUp() throws Exception {

	logger.debug("Setting up before '" + this.testName.getMethodName() + "'");

	int port = SocketUtils.findAvailableTcpPort(61613);

	this.activeMQBroker = new BrokerService();
	this.activeMQBroker.addConnector("stomp://127.0.0.1:" + port);
	this.activeMQBroker.setStartAsync(false);
	this.activeMQBroker.setPersistent(false);
	this.activeMQBroker.setUseJmx(false);
	this.activeMQBroker.getSystemUsage().getMemoryUsage().setLimit(1024 * 1024 * 5);
	this.activeMQBroker.getSystemUsage().getTempUsage().setLimit(1024 * 1024 * 5);
	this.activeMQBroker.start();

	ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler();
	taskScheduler.afterPropertiesSet();

	this.client = new ReactorNettyTcpStompClient("127.0.0.1", port);
	this.client.setMessageConverter(new StringMessageConverter());
	this.client.setTaskScheduler(taskScheduler);
}
 
Example 2
Source File: ReactorNettyTcpStompClientTests.java    From java-technology-stack with MIT License 6 votes vote down vote up
@Before
public void setUp() throws Exception {

	logger.debug("Setting up before '" + this.testName.getMethodName() + "'");

	int port = SocketUtils.findAvailableTcpPort(61613);

	this.activeMQBroker = new BrokerService();
	this.activeMQBroker.addConnector("stomp://127.0.0.1:" + port);
	this.activeMQBroker.setStartAsync(false);
	this.activeMQBroker.setPersistent(false);
	this.activeMQBroker.setUseJmx(false);
	this.activeMQBroker.getSystemUsage().getMemoryUsage().setLimit(1024 * 1024 * 5);
	this.activeMQBroker.getSystemUsage().getTempUsage().setLimit(1024 * 1024 * 5);
	this.activeMQBroker.start();

	ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler();
	taskScheduler.afterPropertiesSet();

	this.client = new ReactorNettyTcpStompClient("127.0.0.1", port);
	this.client.setMessageConverter(new StringMessageConverter());
	this.client.setTaskScheduler(taskScheduler);
}
 
Example 3
Source File: Reactor2TcpStompClientTests.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws Exception {

	logger.debug("Setting up before '" + this.testName.getMethodName() + "'");

	int port = SocketUtils.findAvailableTcpPort(61613);

	this.activeMQBroker = new BrokerService();
	this.activeMQBroker.addConnector("stomp://127.0.0.1:" + port);
	this.activeMQBroker.setStartAsync(false);
	this.activeMQBroker.setPersistent(false);
	this.activeMQBroker.setUseJmx(false);
	this.activeMQBroker.getSystemUsage().getMemoryUsage().setLimit(1024 * 1024 * 5);
	this.activeMQBroker.getSystemUsage().getTempUsage().setLimit(1024 * 1024 * 5);
	this.activeMQBroker.start();

	ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler();
	taskScheduler.afterPropertiesSet();

	this.client = new Reactor2TcpStompClient("127.0.0.1", port);
	this.client.setMessageConverter(new StringMessageConverter());
	this.client.setTaskScheduler(taskScheduler);
}
 
Example 4
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 5
Source File: ProxyTaskScheduler.java    From lemon with Apache License 2.0 6 votes vote down vote up
public void afterPropertiesSet() {
    if (properties != null) {
        for (Map.Entry<Object, Object> entry : properties.entrySet()) {
            String key = (String) entry.getKey();
            String value = (String) entry.getValue();

            if ("scheduler.enabled".equals(key)) {
                continue;
            }

            if (key.startsWith(prefix)) {
                String name = key.substring(prefix.length());
                skipMap.put(name, Boolean.valueOf(value));
                logger.info("{} : {}", name, skipMap.get(name));
            }
        }
    }

    if (enabled) {
        instance = new ThreadPoolTaskScheduler();
        instance.afterPropertiesSet();
    }
}
 
Example 6
Source File: ThreadUtils.java    From rqueue with Apache License 2.0 5 votes vote down vote up
public static ThreadPoolTaskScheduler createTaskScheduler(
    int poolSize, String threadPrefix, int terminationTime) {
  ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
  scheduler.setBeanName(threadPrefix.substring(0, threadPrefix.length() - 1));
  scheduler.setPoolSize(poolSize);
  scheduler.setThreadNamePrefix(threadPrefix);
  scheduler.setAwaitTerminationSeconds(terminationTime);
  scheduler.setRemoveOnCancelPolicy(true);
  scheduler.afterPropertiesSet();
  return scheduler;
}