public synchronized void warmUp() throws Exception { if (endpointDone.compareAndSet(false, true)) { // endpoints should only be started once as they can be reused on other routes // and whatnot, thus their lifecycle is to start once, and only to stop when Camel shutdown for (Route route : routes) { // ensure endpoint is started first (before the route services, such as the consumer) ServiceHelper.startService(route.getEndpoint()); } } if (warmUpDone.compareAndSet(false, true)) { for (Route route : routes) { // warm up the route first route.warmUp(); LOG.debug("Starting services on route: {}", route.getId()); List<Service> services = route.getServices(); // callback that we are staring these services route.onStartingServices(services); // gather list of services to start as we need to start child services as well Set<Service> list = new LinkedHashSet<Service>(); for (Service service : services) { list.addAll(ServiceHelper.getChildServices(service)); } // split into consumers and child services as we need to start the consumers // afterwards to avoid them being active while the others start List<Service> childServices = new ArrayList<Service>(); for (Service service : list) { // inject the route if (service instanceof RouteAware) { ((RouteAware) service).setRoute(route); } if (service instanceof Consumer) { inputs.put(route, (Consumer) service); } else { childServices.add(service); } } startChildService(route, childServices); // fire event EventHelper.notifyRouteAdded(camelContext, route); } // ensure lifecycle strategy is invoked which among others enlist the route in JMX for (LifecycleStrategy strategy : camelContext.getLifecycleStrategies()) { strategy.onRoutesAdd(routes); } // add routes to camel context camelContext.addRouteCollection(routes); } }
@Override protected void doStart() throws Exception { super.doStart(); if (producerCache == null) { producerCache = new ProducerCache(this, getCamelContext(), cacheSize); } ServiceHelper.startService(producerCache); }
@Override protected void doStart() throws Exception { super.doStart(); // validate that if backoff multiplier is in use, the threshold values is set correclty if (backoffMultiplier > 0) { if (backoffIdleThreshold <= 0 && backoffErrorThreshold <= 0) { throw new IllegalArgumentException( "backoffIdleThreshold and/or backoffErrorThreshold must be configured to a positive value when using backoffMultiplier"); } LOG.debug( "Using backoff[multiplier={}, idleThreshold={}, errorThreshold={}] on {}", new Object[] { backoffMultiplier, backoffIdleThreshold, backoffErrorThreshold, getEndpoint() }); } if (scheduler == null) { scheduler = new DefaultScheduledPollConsumerScheduler(); } scheduler.setCamelContext(getEndpoint().getCamelContext()); scheduler.onInit(this); scheduler.scheduleTask(this); // configure scheduler with options from this consumer Map<String, Object> properties = new HashMap<String, Object>(); IntrospectionSupport.getProperties(this, properties, null); IntrospectionSupport.setProperties( getEndpoint().getCamelContext().getTypeConverter(), scheduler, properties); if (schedulerProperties != null && !schedulerProperties.isEmpty()) { // need to use a copy in case the consumer is restarted so we keep the properties Map<String, Object> copy = new HashMap<String, Object>(schedulerProperties); IntrospectionSupport.setProperties( getEndpoint().getCamelContext().getTypeConverter(), scheduler, copy); if (copy.size() > 0) { throw new FailedToCreateConsumerException( getEndpoint(), "There are " + copy.size() + " scheduler parameters that couldn't be set on the endpoint." + " Check the uri if the parameters are spelt correctly and that they are properties of the endpoint." + " Unknown parameters=[" + copy + "]"); } } ObjectHelper.notNull(scheduler, "scheduler", this); ObjectHelper.notNull(pollStrategy, "pollStrategy", this); ServiceHelper.startService(scheduler); if (isStartScheduler()) { startScheduler(); } }
protected void startChildService(Route route, List<Service> services) throws Exception { for (Service service : services) { LOG.debug("Starting child service on route: {} -> {}", route.getId(), service); for (LifecycleStrategy strategy : camelContext.getLifecycleStrategies()) { strategy.onServiceAdd(camelContext, service, route); } ServiceHelper.startService(service); addChildService(service); } }
@Override public long beforePoll(long timeout) throws Exception { LOG.trace("Before poll {}", getEndpoint()); // resume or start our self if (!ServiceHelper.resumeService(this)) { ServiceHelper.startService(this); } // ensure at least timeout is as long as one poll delay return Math.max(timeout, getDelay()); }
@Override protected void doStart() throws Exception { ObjectHelper.notNull(camelContext, "camelContext", this); if (endpoint == null && endpointUri == null) { throw new IllegalArgumentException("Either endpoint or endpointUri must be configured"); } if (endpoint == null) { endpoint = camelContext.getEndpoint(endpointUri); } producer = endpoint.createProducer(); ServiceHelper.startService(producer); }
@Override protected void doStart() throws Exception { super.doStart(); if (cacheManagerFactory == null) { InputStream is = null; if (configurationFile != null) { is = ResourceHelper.resolveMandatoryResourceAsInputStream( getCamelContext().getClassResolver(), configurationFile); } cacheManagerFactory = new DefaultCacheManagerFactory(is, configurationFile); } ServiceHelper.startService(cacheManagerFactory); }
protected void doStart() throws Exception { // ensure we are warmed up before starting the route warmUp(); for (Route route : routes) { // start the route itself ServiceHelper.startService(route); // invoke callbacks on route policy if (route.getRouteContext().getRoutePolicyList() != null) { for (RoutePolicy routePolicy : route.getRouteContext().getRoutePolicyList()) { routePolicy.onStart(route); } } // fire event EventHelper.notifyRouteStarted(camelContext, route); } }
public void start() throws Exception { if (!context.getStatus().isStarted()) { throw new IllegalArgumentException("CamelContext is not started"); } ServiceHelper.startService(getProcessor()); }
@Override protected void doStart() throws Exception { super.doStart(); ServiceHelper.startService(traceHandlers); }
@Override protected void doStart() throws Exception { super.doStart(); ServiceHelper.startService(locks); }
@Override protected void doStart() throws Exception { LOG.info("Starting notifier " + notifier); ServiceHelper.startService(notifier); managementStrategy.addEventNotifier(notifier); }
@Override public void start() throws Exception { ServiceHelper.startService(bulkClient); }
public ObserverSender(Endpoint endpoint) throws Exception { this.producer = endpoint.createProducer(); ServiceHelper.startService(producer); }