Refine search
private String createName(String type) { CamelContext context = route.getRouteContext().getCamelContext(); String name = context.getManagementName() != null ? context.getManagementName() : context.getName(); String answer = namePattern; answer = answer.replaceFirst("##name##", name); answer = answer.replaceFirst("##routeId##", Matcher.quoteReplacement(route.getId())); answer = answer.replaceFirst("##type##", type); return answer; }
private synchronized void startAllStoppedConsumers() { try { for (Route route : suspendedRoutes) { LOGGER.debug("Starting consumer for {} ({})", route.getId(), route.getConsumer()); startConsumer(route.getConsumer()); } suspendedRoutes.clear(); } catch (Exception e) { handleException(e); } }
private void reportNonCustomRouteIDs(Route route) { CamelContext camelContext = route.getRouteContext().getCamelContext(); RouteDefinition routeDefinition = camelContext.getRouteDefinition(route.getId()); if (routeDefinition.getCustomId() == null || !routeDefinition.getCustomId()) { LOG.warn("Problem detected: Route " + StringUtils.quote(route.getId()) + " has no custom ID set! Endpoint URI is " + route.getEndpoint().getEndpointUri()); } }
public RouteInfo(Route route) { this.id = route.getId(); this.description = route.getDescription(); this.uptime = route.getUptime(); this.uptimeMillis = route.getUptimeMillis(); if (route instanceof StatefulService) { this.status = ((StatefulService) route).getStatus().name(); } else { this.status = null; } }
public RouteEndpointInfo(Route route) { this.id = route.getId(); this.group = route.getGroup(); this.description = route.getDescription(); this.uptime = route.getUptime(); this.uptimeMillis = route.getUptimeMillis(); if (route.getProperties() != null) { this.properties = new HashMap<>(route.getProperties()); } else { this.properties = Collections.emptyMap(); } if (route instanceof StatefulService) { this.status = ((StatefulService) route).getStatus().name(); } else { this.status = null; } }
public void scheduleRoute(Action action, Route route) throws Exception { JobDetail jobDetail = createJobDetail(action, route); Trigger trigger = createTrigger(action, route); updateScheduledRouteDetails(action, jobDetail, trigger, route); loadCallbackDataIntoSchedulerContext(jobDetail, action, route); boolean isClustered = route.getRouteContext().getCamelContext().getComponent("quartz2", QuartzComponent.class).isClustered(); if (isClustered) { // check to see if the same job has already been setup through another node of the cluster JobDetail existingJobDetail = getScheduler().getJobDetail(jobDetail.getKey()); if (jobDetail.equals(existingJobDetail)) { if (LOG.isInfoEnabled()) { LOG.info("Skipping to schedule the job: {} for action: {} on route {} as the job: {} already existing inside the cluster", new Object[] {jobDetail.getKey(), action, route.getId(), existingJobDetail.getKey()}); } // skip scheduling the same job again as one is already existing for the same routeId and action return; } } getScheduler().scheduleJob(jobDetail, trigger); if (LOG.isInfoEnabled()) { LOG.info("Scheduled trigger: {} for action: {} on route {}", trigger.getKey(), action, route.getId()); } }
context.start(); List<Route> routes = context.getRoutes(); context.startRoute(route.getId()); logger.info("start",null, "---OR Route in Camel Context-"+route.getEndpoint().getEndpointUri()+" Route State:"+context.getRouteStatus(route.getId()));
@Override public void onInit(Route route) { super.onInit(route); if (getMeterRegistry() == null) { setMeterRegistry(MicrometerUtils.getOrCreateMeterRegistry( route.getRouteContext().getCamelContext().getRegistry(), METRICS_REGISTRY_NAME)); } try { MicrometerRoutePolicyService registryService = route.getRouteContext().getCamelContext().hasService(MicrometerRoutePolicyService.class); if (registryService == null) { registryService = new MicrometerRoutePolicyService(); registryService.setMeterRegistry(getMeterRegistry()); registryService.setPrettyPrint(isPrettyPrint()); registryService.setDurationUnit(getDurationUnit()); registryService.setMatchingTags(Tags.of(SERVICE_NAME, MicrometerRoutePolicyService.class.getSimpleName())); route.getRouteContext().getCamelContext().addService(registryService); ServiceHelper.startService(registryService); } } catch (Exception e) { throw ObjectHelper.wrapRuntimeCamelException(e); } // create statistics holder // for now we record only all the timings of a complete exchange (responses) // we have in-flight / total statistics already from camel-core statistics = new MetricsStatistics(getMeterRegistry(), route, getNamingStrategy()); }
/** * Allows to stop a route asynchronously using a separate background thread which can allow any current in-flight exchange * to complete while the route is being shutdown. * You may attempt to stop a route from processing an exchange which would be in-flight and therefore attempting to stop * the route will defer due there is an inflight exchange in-progress. By stopping the route independently using a separate * thread ensures the exchange can continue process and complete and the route can be stopped. */ // TODO: in Camel 2.19 there is a stopRouteAsync method we can use private void stopCurrentRouteAsync(final Route route) { String threadId = route.getRouteContext().getCamelContext().getExecutorServiceManager().resolveThreadName("StopRouteAsync"); Runnable task = () -> { try { route.getRouteContext().getCamelContext().stopRoute(route.getId()); } catch (Exception e) { handleException(e); } }; new Thread(task, threadId).start(); }
ManagedRouteMBean managedRoute = context.getManagedRoute(route.getId(), ManagedRouteMBean.class); if (managedRoute.getExchangesTotal() == 0) { uncoveredRoutes.add(route.getId()); routesSummary.append("\t\tRoute ").append(route.getId()).append(" total: ").append(managedRoute.getExchangesTotal()).append(" (").append(routeCoveragePercentage).append("%)\n"); List<ManagedProcessorMBean> processors = processorsForRoute.get(route.getId()); if (processors != null) { for (ManagedProcessorMBean managedProcessor : processors) {
for (Route route : camelContext.getRoutes()) { Endpoint endpoint = route.getEndpoint(); if (endpoint instanceof DelegateEndpoint) { endpoint = ((DelegateEndpoint)endpoint).getEndpoint(); if (camelContext.hasEndpoint(endpointUri) != null) { return camelContext.getEndpoint(endpointUri, QuartzEndpoint.class); } else { LOG.warn("Cannot find existing QuartzEndpoint with uri: {}. Creating new endpoint instance.", endpointUri);
List<Route> routes = context.getRoutes(); for (Route route : routes) { if ( !route.getId().startsWith("mina")) { logger.info(methodName, null, "Stopping Route:"+route.getId()); route.getConsumer().stop(); route.getEndpoint().stop(); ActiveMQComponent amqc = (ActiveMQComponent) context.getComponent("activemq"); amqc.stop(); amqc.shutdown();
protected void onJobExecute(Action action, Route route) throws Exception { LOG.debug("Scheduled Event notification received. Performing action: {} on route: {}", action, route.getId()); ServiceStatus routeStatus = route.getRouteContext().getCamelContext().getRouteStatus(route.getId()); if (action == Action.START) { if (routeStatus == ServiceStatus.Stopped) { startRoute(route); } else if (ServiceHelper.isSuspended(route.getConsumer())) { resumeOrStartConsumer(route.getConsumer()); suspendOrStopConsumer(route.getConsumer()); } else { LOG.warn("Route is not in a started state and cannot be suspended. The current route state is {}", routeStatus); if (ServiceHelper.isSuspended(route.getConsumer())) { resumeOrStartConsumer(route.getConsumer()); } else { LOG.warn("The Consumer {} is not suspended and cannot be resumed.", route.getConsumer());
@Override public synchronized void onInit(Route route) { super.onInit(route); LOGGER.info("Route managed by {}. Setting route {} AutoStartup flag to false.", getClass(), route.getId()); route.getRouteContext().getRoute().setAutoStartup("false"); stoppeddRoutes.add(route); this.refCount.retain(); startManagedRoutes(); }
public String dashboard(Model model) { if (LOG.isDebugEnabled()) { LOG.debug("camel context is suspended : " + camelContext.isSuspended()); List<Route> routes = camelContext.getRoutes(); List<RouteStatus> routeStatuses = new ArrayList<RouteStatus>(); for (Route r : routes) { RouteStatus rs = new RouteStatus(); rs.setId(r.getId()); rs.setServiceStatus(camelContext.getRouteStatus(r.getId())); routeStatuses.add(rs);
public RouteDetailsInfo(final CamelContext camelContext, final Route route) { super(route); if (camelContext.getManagementStrategy().getManagementAgent() != null) { this.routeDetails = new RouteDetails(camelContext.getManagedRoute(route.getId(), ManagedRouteMBean.class)); } }
@Override public void onInit(Consumer consumer) { this.consumer = consumer; // find the route of the consumer for (Route route : consumer.getEndpoint().getCamelContext().getRoutes()) { if (route.getConsumer() == consumer) { this.routeId = route.getId(); break; } } }
private void startAllStoppedRoutes() { try { lock.lock(); if (!suspendedRoutes.isEmpty()) { if (log.isDebugEnabled()) { log.info("{} route(s) have been stopped previously by policy, restarting.", suspendedRoutes.size()); } for (Route suspended : suspendedRoutes) { DefaultCamelContext ctx = (DefaultCamelContext)suspended.getRouteContext().getCamelContext(); while (!ctx.isStarted()) { log.info("Context {} is not started yet. Sleeping for a bit.", ctx.getName()); Thread.sleep(5000); } log.info("Starting route [{}] defined in context [{}].", suspended.getId(), ctx.getName()); startRoute(suspended); } suspendedRoutes.clear(); } } catch (Exception e) { handleException(e); } finally { lock.unlock(); } }
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException { LOG.debug("Running ScheduledJob: jobExecutionContext={}", jobExecutionContext); SchedulerContext schedulerContext = getSchedulerContext(jobExecutionContext); ScheduledJobState state = (ScheduledJobState) schedulerContext.get(jobExecutionContext.getJobDetail().getKey().toString()); Action storedAction = state.getAction(); Route storedRoute = state.getRoute(); List<RoutePolicy> policyList = storedRoute.getRouteContext().getRoutePolicyList(); for (RoutePolicy policy : policyList) { try { if (policy instanceof ScheduledRoutePolicy) { ((ScheduledRoutePolicy)policy).onJobExecute(storedAction, storedRoute); } } catch (Exception e) { throw new JobExecutionException("Failed to execute Scheduled Job for route " + storedRoute.getId() + " with trigger name: " + jobExecutionContext.getTrigger().getKey(), e); } } }
private void ensureElectionIsCreated(Route route) { if (election == null) { electionLock.lock(); try { if (election == null) { // re-test election = new ZooKeeperElection(route.getRouteContext().getCamelContext(), uri, enabledCount); election.addElectionWatcher(this); } } finally { electionLock.unlock(); } } }