Refine search
@Override protected void doShutdown() throws Exception { ServiceHelper.stopAndShutdownService(map); if (scheduledExecutorService != null && stopScheduledExecutorService) { camelContext.getExecutorServiceManager().shutdown(scheduledExecutorService); scheduledExecutorService = null; } if (workerPool != null && stopWorkerPool) { camelContext.getExecutorServiceManager().shutdown(workerPool); workerPool = null; } }
public ErpProducer(Endpoint endpoint) { super(endpoint); // use Camel to create the thread pool for us this.executor = endpoint.getCamelContext().getExecutorServiceManager().newFixedThreadPool(this, "ERP", 10); }
@Override public void shutdown() { camelContext.getExecutorServiceManager().shutdownNow(getScheduledExecutor()); } }
@Override protected void doStart() throws Exception { ObjectHelper.notNull(camelContext, "CamelContext", this); timeoutLogger = new CamelLogger(LOG, timeoutLoggingLevel); if (scheduledExecutorService == null) { scheduledExecutorService = camelContext.getExecutorServiceManager().newSingleThreadScheduledExecutor(this, "NettyTimeoutCorrelationManager"); } if (workerPool == null) { workerPool = camelContext.getExecutorServiceManager().newDefaultThreadPool(this, "NettyTimeoutWorkerPool"); } map = new NettyStateTimeoutMap(scheduledExecutorService); ServiceHelper.startService(map); }
private void terminateApplicationContext(final ConfigurableApplicationContext applicationContext, final CamelContext camelContext, final CountDownLatch latch) { ExecutorService executorService = camelContext.getExecutorServiceManager().newSingleThreadExecutor(this, "CamelSpringBootTerminateTask"); Runnable task = () -> { try { latch.await(); LOG.info("CamelSpringBoot triggering shutdown of the JVM."); // we need to run a daemon thread to stop ourselves so this thread pool can be stopped nice also new Thread(applicationContext::close).start(); } catch (Throwable e) { // ignore } }; executorService.submit(task); }
@Override protected void doStop() throws Exception { closeConnectionAndChannel(); if (executor != null) { if (endpoint != null && endpoint.getCamelContext() != null) { endpoint.getCamelContext().getExecutorServiceManager().shutdownNow(executor); } else { executor.shutdownNow(); } executor = null; } }
@Override protected void doStart() throws Exception { super.doStart(); log.info("Starting CouchDB consumer"); executor = endpoint.getCamelContext().getExecutorServiceManager().newFixedThreadPool(this, endpoint.getEndpointUri(), 1); task = new CouchDbChangesetTracker(endpoint, this, couchClient); executor.submit(task); }
@Override protected void doStart() throws Exception { super.doStart(); executor = endpoint.getCamelContext().getExecutorServiceManager().newFixedThreadPool(this, endpoint.getEndpointUri(), 1); executor.execute(this); }
if (os.toLowerCase(Locale.US).startsWith("mac")) { Class<WatchEvent.Modifier> clazz = getCamelContext().getClassResolver().resolveClass("com.sun.nio.file.SensitivityWatchEventModifier", WatchEvent.Modifier.class); if (clazz != null) { WatchEvent.Modifier[] modifiers = clazz.getEnumConstants(); executorService = getCamelContext().getExecutorServiceManager().newSingleThreadExecutor(this, "FileWatcherStrategy"); executorService.submit(task); } catch (IOException e) { throw ObjectHelper.wrapRuntimeCamelException(e);
@Override protected void doStart() throws Exception { super.doStart(); executor = getEndpoint().getCamelContext().getExecutorServiceManager().newSingleThreadExecutor(this, "Beanstalk-Producer"); executor.execute(new Runnable() { public void run() { initClient(); } }); }
@Override protected void doStop() throws Exception { log.info("Stopping Kafka consumer on topic: {}", endpoint.getConfiguration().getTopic()); if (executor != null) { if (getEndpoint() != null && getEndpoint().getCamelContext() != null) { getEndpoint().getCamelContext().getExecutorServiceManager().shutdownGraceful(executor); } else { executor.shutdownNow(); } if (!executor.isTerminated()) { tasks.forEach(KafkaFetchRecords::shutdown); executor.shutdownNow(); } } tasks.clear(); executor = null; if (stopOffsetRepo) { StateRepository repo = endpoint.getConfiguration().getOffsetRepository(); log.debug("Stopping OffsetRepository: {}", repo); ServiceHelper.stopAndShutdownService(repo); } super.doStop(); }
public void serve() { try { serverTransport_.listen(); } catch (TTransportException ttx) { LOGGER.error("Error occurred during listening.", ttx); return; } // Run the preServe event if (eventHandler_ != null) { eventHandler_.preServe(); } startExecutor.execute(() -> { stopped_ = false; setServing(true); waitForShutdown(); context.getExecutorServiceManager().shutdownGraceful(invoker); setServing(false); }); }
private void terminateMainControllerAfter(final CamelContext camelContext, int seconds, final AtomicBoolean completed, final CountDownLatch latch) { ScheduledExecutorService executorService = camelContext.getExecutorServiceManager().newSingleThreadScheduledExecutor(this, "CamelSpringBootTerminateTask"); Runnable task = () -> { LOG.info("CamelSpringBoot triggering shutdown of the JVM."); try { camelContext.stop(); } catch (Throwable e) { LOG.warn("Error during stopping CamelContext", e); } finally { completed.set(true); latch.countDown(); } }; executorService.schedule(task, seconds, TimeUnit.SECONDS); }
@Override public void stop() { super.stop(); context.getExecutorServiceManager().shutdownGraceful(startExecutor); }
@Override public void start() throws Exception { if (this.executor == null) { this.executor = camelContext.getExecutorServiceManager().newSingleThreadScheduledExecutor(this, "CamelKubernetesLeaderNotifier"); } }
public CamelCloudClient(CamelCloudService cloudService, CamelContext camelContext, String applicationId, String baseEndpoint) { this.cloudService = cloudService; this.camelContext = camelContext; this.producerTemplate = camelContext.createProducerTemplate(); this.applicationId = applicationId; this.baseEndpoint = baseEndpoint; this.executorService = camelContext.getExecutorServiceManager().newThreadPool(this, "CamelCloudClient/" + applicationId, 0, 1); }
/** * Create Producer to PIN with OUTPUT mode * * @param endpoint * the endpoint * @param pin * the pin to manage * @param action * the action to do */ public GPIOProducer(GPIOEndpoint endpoint, GpioPin pin, GPIOAction action) { super(endpoint); this.pin = pin; this.action = action; this.pool = this.getEndpoint().getCamelContext().getExecutorServiceManager().newSingleThreadExecutor(this, Pi4jConstants.CAMEL_PI4J_GPIO_THREADPOOL); }
LOGGER.debug("Creating new executor with {} threads", newSize); executor = component.getCamelContext().getExecutorServiceManager().newFixedThreadPool(this, uri, newSize); } else if (executor != null && newSize <= 0) { LOGGER.debug("Shutting down executor"); component.getCamelContext().getExecutorServiceManager().shutdown(executor); executor = null; } else if (executor instanceof ThreadPoolExecutor) { LOGGER.debug("Shutting down old and creating new executor with {} threads", newSize); component.getCamelContext().getExecutorServiceManager().shutdown(executor); executor = component.getCamelContext().getExecutorServiceManager().newFixedThreadPool(this, uri, newSize);
protected ReplyManager createReplyManager(String replyTo) throws Exception { // use a regular queue ReplyManager replyManager = new QueueReplyManager(getEndpoint().getCamelContext()); replyManager.setEndpoint(getEndpoint()); String name = "JmsReplyManagerTimeoutChecker[" + replyTo + "]"; ScheduledExecutorService replyManagerScheduledExecutorService = getEndpoint().getCamelContext().getExecutorServiceManager().newSingleThreadScheduledExecutor(name, name); replyManager.setScheduledExecutorService(replyManagerScheduledExecutorService); name = "JmsReplyManagerOnTimeout[" + replyTo + "]"; // allow the timeout thread to timeout so during normal operation we do not have a idle thread int max = getEndpoint().getReplyToOnTimeoutMaxConcurrentConsumers(); if (max <= 0) { throw new IllegalArgumentException("The option replyToOnTimeoutMaxConcurrentConsumers must be >= 1"); } ExecutorService replyManagerExecutorService = getEndpoint().getCamelContext().getExecutorServiceManager().newThreadPool(replyManager, name, 0, max); replyManager.setOnTimeoutExecutorService(replyManagerExecutorService); ServiceHelper.startService(replyManager); return replyManager; }
private void init() { if (this.workerPool == null) { this.workerPool = context.getExecutorServiceManager().newThreadPool( this, configuration.getThreadPoolName(), configuration.getThreadPoolMinSize(), configuration.getThreadPoolMaxSize() ); } }