public void destroy() throws Exception { if (consumer != null) { ServiceHelper.stopAndShutdownService(consumer); } }
protected synchronized void removeNotifier(String id) { NotifierRegistration registration = notifierMap.remove(id); if (registration != null) { try { ServiceHelper.stopAndShutdownService(registration); } catch (Exception e) { LOG.error("Failed to stop registration " + registration + " for CamelContext " + id + ". Reason: " + e, e); } } }
@Override protected void doStop() throws Exception { LOG.info("Stopping " + notifier); managementStrategy.removeEventNotifier(notifier); ServiceHelper.stopAndShutdownService(notifier); } }
protected void removeMapping(Path path) { try { String url = toUrlString(path); LOG.info("Removing Dozer Mapping file " + url); WatcherDozerTypeConverterLoader loader = loaders.remove(url); if (url != null) { // remove by stopping the loader ServiceHelper.stopAndShutdownService(loader); camelContext.removeService(loader); } } catch (Exception e) { LOG.warn("Ignored path " + path + " due to: " + e, e); } }
private void updateMapping(String url) { LOG.info("Updating Dozer Mapping file " + url); WatcherDozerTypeConverterLoader loader = loaders.get(url); if (url != null) { try { // update by restarting loader ServiceHelper.stopAndShutdownService(loader); camelContext.removeService(loader); ServiceHelper.startService(loader); } catch (Exception e) { LOG.warn("Error updating dozer mapping due to: " + e, e); } } }
/** * If needed, close Connection and Channels */ private void closeConnectionAndChannel() throws IOException, TimeoutException { if (startConsumerCallable != null) { startConsumerCallable.stop(); } for (RabbitConsumer consumer : this.consumers) { try { ServiceHelper.stopAndShutdownService(consumer); } catch (Exception e) { log.warn("Error occurred while stopping consumer. This exception is ignored", e); } } this.consumers.clear(); if (conn != null) { log.debug("Closing connection: {} with timeout: {} ms.", conn, closeTimeout); conn.close(closeTimeout); conn = null; } }
@Override protected void doStop() throws Exception { // stop event notifier camelContext.getManagementStrategy().removeEventNotifier(eventNotifier); ServiceHelper.stopService(eventNotifier); // stop and close collector ServiceHelper.stopAndShutdownService(spanReporter); if (spanReporter instanceof Closeable) { IOHelper.close((Closeable) spanReporter); } // clear braves braves.clear(); // remove route policy camelContext.getRoutePolicyFactories().remove(this); }
@Override public void doStop() throws Exception { if (executor != null) { endpoint.getCamelContext().getExecutorServiceManager().shutdownNow(executor); executor = null; } ServiceHelper.stopAndShutdownService(fileWatcher); lines.clear(); // do not close regular inputStream as it may be System.in etc. IOHelper.close(inputStreamToClose); super.doStop(); }
@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; } }
@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(); }