@Override protected ScheduledExecutorService createExecutor(int poolSize, ThreadFactory threadFactory, RejectedExecutionHandler rejectedExecutionHandler) { return camelContext.getExecutorServiceManager().newScheduledThreadPool(source, name, poolSize); }
@Override protected void doStart() throws Exception { super.doStart(); // create a scheduled thread pool with 1 thread as we only need one task as background task executor = getCamelContext().getExecutorServiceManager().newScheduledThreadPool(this, "MyBackgroundTask", 1); // schedule the task to run once every second executor.scheduleWithFixedDelay(this, 1, 1, TimeUnit.SECONDS); }
@Override protected void doStart() throws Exception { super.doStart(); // create a scheduled thread pool with 1 thread as we only need one task as background task executor = getCamelContext().getExecutorServiceManager().newScheduledThreadPool(this, "MyBackgroundTask", 1); // schedule the task to run once every second executor.scheduleWithFixedDelay(this, 1, 1, TimeUnit.SECONDS); }
protected static synchronized ExecutorService getExecutorService(CamelContext context) { // CamelContext will shutdown thread pool when it shutdown so we can // lazy create it on demand // but in case of hot-deploy or the likes we need to be able to // re-create it (its a shared static instance) if (executorService == null || executorService.isTerminated() || executorService.isShutdown()) { final ExecutorServiceManager manager = context.getExecutorServiceManager(); // try to lookup a pool first based on profile ThreadPoolProfile poolProfile = manager.getThreadPoolProfile( FacebookConstants.FACEBOOK_THREAD_PROFILE_NAME); if (poolProfile == null) { poolProfile = manager.getDefaultThreadPoolProfile(); } // create a new pool using the custom or default profile executorService = manager.newScheduledThreadPool(FacebookProducer.class, FacebookConstants.FACEBOOK_THREAD_PROFILE_NAME, poolProfile); } return executorService; }