/** * Stops the streamer. * * @throws IgniteException In cases if failed to stop the streamer. */ public void stop() throws IgniteException { // If the Camel Context is stopping or stopped, reject this call to stop. if (camelCtx.getStatus() == ServiceStatus.Stopped || camelCtx.getStatus() == ServiceStatus.Stopping) throw new IgniteException("Failed to stop Camel streamer (CamelContext already stopped or stopping)."); // Stop Camel services. try { ServiceHelper.stopAndShutdownServices(camelCtx, endpoint, consumer); } catch (Exception e) { throw new IgniteException("Failed to stop Camel streamer [errMsg=" + e.getMessage() + ']'); } U.log(log, "Stopped Camel streamer, formerly consuming from endpoint URI: " + endpointUri); }
@Override public boolean isConnected() { return this.camelContext.getStatus() == Started; }
@Override public boolean isConnected() { return this.camelContext.getStatus() == Started; }
void bindCamelContexts(CamelContext camelContext) { if (camelContext != null) { if (LOG.isDebugEnabled()) { LOG.debug("Bind camelContext " + camelContext + " status: " + camelContext.getStatus()); } String id = camelContext.getName(); this.camelContexts.put(id, camelContext); clearCamelContextConfiguration(id); } }
void unbindCamelContexts(CamelContext camelContext) { if (camelContext != null) { if (LOG.isDebugEnabled()) { LOG.debug("Unbind camelContext " + camelContext + " status: " + camelContext.getStatus()); } String id = camelContext.getName(); this.camelContexts.remove(id); clearCamelContextConfiguration(id); } }
void unbindCamelContexts(CamelContext camelContext) { if (camelContext != null) { if (LOG.isDebugEnabled()) { LOG.debug("Unbind camelContext " + camelContext + " status: " + camelContext.getStatus()); } String id = camelContext.getName(); this.camelContexts.remove(id); clearCamelContextConfiguration(id); } }
void bindCamelContexts(CamelContext camelContext) { if (camelContext != null) { if (LOG.isDebugEnabled()) { LOG.debug("Bind camelContext " + camelContext + " status: " + camelContext.getStatus()); } String id = camelContext.getName(); this.camelContexts.put(id, camelContext); clearCamelContextConfiguration(id); } }
@Override public Object evaluate(Exchange exchange) { return exchange.getContext().getStatus().isStarted() ? 0 : delay; } };
@PreDestroy public void destroy() throws Exception { if (getCamelContext().getStatus().isStarted()) { getCamelContext().stop(); } }
public synchronized EventEngine getEventEngine(CamelContext context, String type) throws Exception { EventEngine eventEngine = engineMap.get(type); if (eventEngine == null) { FactoryFinder ff = context.getFactoryFinder("META-INF/services/org/fusesource/eca/engine/"); if (ff != null) { eventEngine = (EventEngine) ff.newInstance(type); eventEngine.initialize(context, type); engineMap.put(type, eventEngine); if (context.getStatus().isStarted() || context.getStatus().isStarting()) { eventEngine.start(); } } } return eventEngine; }
public synchronized EventCacheManager getEventCacheManager(CamelContext context, String type) throws Exception { EventCacheManager eventCacheManager = cacheMap.get(type); if (eventCacheManager == null) { FactoryFinder ff = context.getFactoryFinder("META-INF/services/org/fusesource/eca/eventcache/"); if (ff != null) { eventCacheManager = (EventCacheManager) ff.newInstance(type); cacheMap.put(type, eventCacheManager); if (context.getStatus().isStarted()) { eventCacheManager.start(); } } } return eventCacheManager; }
@Override @PostConstruct public void init() throws Exception { producerTemplate = context.createProducerTemplate(); if (context.getStatus().isStopped()) { context.start(); } super.init(); }
@Override public void run() { try { ServiceStatus status = context.getStatus(); if (status.isSuspended()){ context.start(); }else if(status.isStarted()){ context.suspend(); } } catch (Exception e) { LOG.error("Cannot start or suspend Camel Context",e); } } }).start();
@Override public void dispose(T context) { super.dispose(context); if (!context.getStatus().isStopped()) { logger.info("Camel CDI is stopping Camel context [{}]", context.getName()); try { context.stop(); } catch (Exception cause) { throw wrapRuntimeCamelException(cause); } } }
@Override @PostConstruct public void init() throws Exception { // Make sure the camel context get started // See https://issues.apache.org/jira/browse/JAMES-1069 if (getCamelContext().getStatus().isStopped()) { getCamelContext().start(); } super.init(); }
@Override protected boolean runningAllowed() { // we can stop quickly if CamelContext is being stopped, and we do not accept messages while stopping // this allows a more cleanly shutdown of the message listener boolean quickStop = false; if (isAllowQuickStop() && !endpoint.isAcceptMessagesWhileStopping()) { quickStop = endpoint.getCamelContext().getStatus().isStopping(); } if (quickStop) { // log at debug level so its quicker to see we are stopping quicker from the logs logger.debug("runningAllowed() -> false due CamelContext is stopping and endpoint configured to not accept messages while stopping"); return false; } else { // otherwise we only run if the endpoint is running boolean answer = endpoint.isRunning(); // log at trace level as otherwise this can be noisy during normal operation logger.trace("runningAllowed() -> " + answer); return answer; } }
@Override public void run() { try { if (context.getStatus().isSuspended()){ context.resume(); //target.add(CamelWidget.this.form); }else if (!context.getStatus().isStarted()){ clearContext(context); String script = getDocument().field("script"); RoutesDefinition routes = context.loadRoutesDefinition(new ByteArrayInputStream( script.getBytes())); context.addRouteDefinitions(routes.getRoutes()); context.start(); } } catch (Exception e) { LOG.error("Cannot start or resume Camel Context",e); } } }).start();
@Override public void contribute(Info.Builder builder) { if (camelContext != null) { builder.withDetail("camel.name", camelContext.getName()); builder.withDetail("camel.version", camelContext.getVersion()); if (camelContext.getUptime() != null) { builder.withDetail("camel.uptime", camelContext.getUptime()); builder.withDetail("camel.uptimeMillis", camelContext.getUptimeMillis()); } builder.withDetail("camel.status", camelContext.getStatus().name()); } } }