Java Code Examples for org.springframework.core.task.TaskExecutor#execute()

The following examples show how to use org.springframework.core.task.TaskExecutor#execute() . 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: WebSocketConfig.java    From kafka-webview with MIT License 6 votes vote down vote up
/**
 * Manages kafka consumers running in a background processing thread for websocket consumers.
 * @param webKafkaConsumerFactory Factory for creating new Consumers
 * @param messagingTemplate messaging template instance for passing websocket messages.
 * @param backgroundConsumerExecutor The executor to run our manager in.
 * @param appProperties defined app properties.
 * @return manager instance for web socket consumers.
 */
@Bean
public WebSocketConsumersManager getWebSocketConsumersManager(
    final WebKafkaConsumerFactory webKafkaConsumerFactory,
    final SimpMessagingTemplate messagingTemplate,
    final TaskExecutor backgroundConsumerExecutor,
    final AppProperties appProperties) {

    // Create manager
    final WebSocketConsumersManager manager = new WebSocketConsumersManager(
        webKafkaConsumerFactory,
        messagingTemplate,
        appProperties.getMaxConcurrentWebSocketConsumers()
    );

    // Submit to executor service
    backgroundConsumerExecutor.execute(manager);

    return manager;
}
 
Example 2
Source File: FollowingService.java    From usergrid with Apache License 2.0 6 votes vote down vote up
public void copyActivityFeed( final EntityRef connectingEntity, final EntityRef connectedEntityRef )
        throws Exception {
    if (logger.isTraceEnabled()) {
        logger.trace("Copying activities to feed...");
    }
    TaskExecutor taskExecutor = ( TaskExecutor ) getApplicationContext().getBean( "taskExecutor" );
    taskExecutor.execute( new Runnable() {
        @Override
        public void run() {
            try {
                em.copyRelationships( connectedEntityRef, "activities", connectingEntity, "feed" );
            }
            catch ( Exception e ) {
                logger.error( "Error while copying activities into feed", e );
            }
        }
    } );
}
 
Example 3
Source File: InstrumentApplication.java    From prom_lab with MIT License 5 votes vote down vote up
@Bean
public CommandLineRunner schedulingRunner(TaskExecutor executor) {
	return new CommandLineRunner() {
		public void run(String... args) throws Exception {
			// 10 jobs per worker
			workerManager = new WorkerManager(queue, 1, 4, 10);
			executor.execute(workerManager);
			System.out.println("WorkerManager thread started...");
		}
	};
}
 
Example 4
Source File: HttpSimulatorApplication.java    From prom_lab with MIT License 5 votes vote down vote up
@Bean
public CommandLineRunner schedulingRunner(TaskExecutor executor) {
	return new CommandLineRunner() {
		public void run(String... args) throws Exception {
			simulator = new ActivitySimulator(opts);
			executor.execute(simulator);
			System.out.println("Simulator thread started...");
		}
	};
}