@Override public void onExchangeBegin(Route route, Exchange exchange) { // use route policy to track events when Camel a Camel route begins/end the lifecycle of an Exchange // these events corresponds to Zipkin server events String serviceName = getServiceName(exchange, route.getEndpoint(), true, false); Tracing brave = getTracing(serviceName); if (brave != null) { serverRequest(brave, serviceName, exchange); } }
@Override public void onExchangeDone(Route route, Exchange exchange) { String serviceName = getServiceName(exchange, route.getEndpoint(), true, false); Tracing brave = getTracing(serviceName); if (brave != null) { serverResponse(brave, serviceName, exchange); } } }
protected Runnable onDisconnected() { return () -> { masterConsumer.set(false); try { stopConsumer(route.getConsumer()); } catch (Exception e) { log.warn("Failed to stop master consumer: {}", route.getEndpoint(), e); } }; }
private void ensureNoDupTriggerKey() { for (Route route : getCamelContext().getRoutes()) { if (route.getEndpoint() instanceof QuartzEndpoint) { QuartzEndpoint quartzEndpoint = (QuartzEndpoint) route.getEndpoint(); TriggerKey checkTriggerKey = quartzEndpoint.getTriggerKey(); if (triggerKey.equals(checkTriggerKey)) { throw new IllegalArgumentException("Trigger key " + triggerKey + " is already in use by " + quartzEndpoint); } } } }
protected Runnable onLockOwned() { return () -> { if (masterConsumer.compareAndSet(false, true)) { try { // ensure endpoint is also started log.info("Elected as master. Starting consumer: {}", route.getEndpoint()); startConsumer(route.getConsumer()); // Lets show we are starting the consumer. thisNodeState = createNodeState(); thisNodeState.setStarted(true); groupListener.updateState(thisNodeState); } catch (Exception e) { log.error("Failed to start master consumer for: {}", route.getEndpoint(), e); } log.info("Elected as master. Consumer started: {}", route.getEndpoint()); } }; }
public void onRoutesAdd(Collection<Route> routes) { /* * LifecycleStrategySupport.onEndpointAdd() is not called for CxfRsEndpoints created via direct constructor * invocation. Therefore we check if the buses on CxfRsEndpoints are correct. */ for (Route route : routes) { final Endpoint endpoint = route.getEndpoint(); if (endpoint instanceof CxfRsEndpoint) { final CxfRsEndpoint rsEnspoint = (CxfRsEndpoint) endpoint; final Bus endpointBus = rsEnspoint.getBus(); if (endpointBus == null || (endpointBus != bus && !(endpointBus .getExtension(HttpDestinationFactory.class) instanceof UndertowDestinationFactory))) { /* Not a correct bus instance */ throw new IllegalStateException("A " + CxfRsEndpoint.class.getName() + " used in route " + route + " either does not have " + Bus.class.getName() + " set or the " + Bus.class.getSimpleName() + " set was not created using correct context class loader." + " This is known to happen for " + CxfRsEndpoint.class.getName() + " instances created by direct constructor invocation." + " Consider using camelContext.getEndpoint(\"cxfrs:http[s]://my-host/my-endpoint\", CxfRsEndpoint.class) instead" + " or add your manually created endpoint to the context management manually using CamelContext.addEndpoint(String uri, Endpoint endpoint)"); } } } }
@Override public void onExchangeDone(Route route, Exchange exchange) { try { if (isExcluded(exchange, route.getEndpoint())) { return; } Span span = ActiveSpanManager.getSpan(exchange); if (span != null) { if (LOG.isTraceEnabled()) { LOG.trace("OpenTracing: finish server span={}", span); } SpanDecorator sd = getSpanDecorator(route.getEndpoint()); sd.post(span, exchange, route.getEndpoint()); span.finish(); ActiveSpanManager.deactivate(exchange); } else { LOG.warn("OpenTracing: could not find managed span for exchange={}", exchange); } } catch (Throwable t) { // This exception is ignored LOG.warn("OpenTracing: Failed to capture tracing data", t); } } }
@Override public void onExchangeBegin(Route route, Exchange exchange) { try { if (isExcluded(exchange, route.getEndpoint())) { return; } SpanDecorator sd = getSpanDecorator(route.getEndpoint()); Span span = tracer.buildSpan(sd.getOperationName(exchange, route.getEndpoint())) .asChildOf(tracer.extract(Format.Builtin.TEXT_MAP, sd.getExtractAdapter(exchange.getIn().getHeaders(), encoding))) .withTag(Tags.SPAN_KIND.getKey(), sd.getReceiverSpanKind()).start(); sd.pre(span, exchange, route.getEndpoint()); ActiveSpanManager.activate(exchange, span); if (LOG.isTraceEnabled()) { LOG.trace("OpenTracing: start server span={}", span); } } catch (Throwable t) { // This exception is ignored LOG.warn("OpenTracing: Failed to capture tracing data", t); } }
private CamelNodeState createNodeState() { String containerId = getContainerIdFactory().newContainerId(); CamelNodeState state = new CamelNodeState(getGroupName(), containerId); state.setConsumer(route.getEndpoint().getEndpointUri()); return state; }
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()); } }
Endpoint endpoint = route.getEndpoint(); if (endpoint instanceof DelegateEndpoint) { endpoint = ((DelegateEndpoint)endpoint).getEndpoint();
Endpoint endpoint = route.getEndpoint(); if (endpoint instanceof DelegateEndpoint) { endpoint = ((DelegateEndpoint)endpoint).getEndpoint();
logger.info(methodName, null, "Stopping Route:"+route.getId()); route.getConsumer().stop(); route.getEndpoint().stop();
logger.info("start",null, "---OR Route in Camel Context-"+route.getEndpoint().getEndpointUri()+" Route State:"+context.getRouteStatus(route.getId()));
@Override protected void doStart() throws Exception { super.doStart(); ObjectHelper.notNull(camelContext, "CamelContext"); ObjectHelper.notEmpty("groupName", groupName); String path = getCamelClusterPath(groupName); this.groupListener = new ZookeeperGroupListenerSupport(path, route.getEndpoint(), onLockOwned(), onDisconnected()); this.groupListener.setCamelContext(camelContext); this.groupListener.setCurator(curator); this.groupListener.setMaximumConnectionTimeout(maximumConnectionTimeout); this.groupListener.setZooKeeperUrl(zooKeeperUrl); this.groupListener.setZooKeeperPassword(zooKeeperPassword); ServiceHelper.startService(groupListener); log.info("Attempting to become master for endpoint: " + route.getEndpoint() + " in " + getCamelContext() + " with singletonID: " + getGroupName()); thisNodeState = createNodeState(); groupListener.updateState(thisNodeState); }