/** * 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); }
public Producer createProducer() throws Exception { ObjectHelper.notNull(applicationContext, "applicationContext"); return new DefaultProducer(this) { public void process(Exchange exchange) throws Exception { ApplicationEvent event = toApplicationEvent(exchange); applicationContext.publishEvent(event); } }; }
@Override protected void starting(Description description) { watch.restart(); }
protected Class<?> getBeanClass(Element element) { ErrorHandlerType type = ErrorHandlerType.DefaultErrorHandler; if (ObjectHelper.isNotEmpty(element.getAttribute("type"))) { type = ErrorHandlerType.valueOf(element.getAttribute("type")); } return type.getTypeAsClass(); }
protected TransactionErrorHandler createTransactionErrorHandler(RouteContext routeContext, Processor processor, ErrorHandlerBuilder builder) { TransactionErrorHandler answer; try { answer = (TransactionErrorHandler) builder.createErrorHandler(routeContext, processor); } catch (Exception e) { throw ObjectHelper.wrapRuntimeCamelException(e); } return answer; }
protected void doStop() throws Exception { super.doStop(); if (additionalApplicationContext != null) { LOG.debug("Stopping Additional ApplicationContext: {}", additionalApplicationContext.getId()); IOHelper.close(additionalApplicationContext); } if (applicationContext != null) { LOG.debug("Stopping Spring ApplicationContext: {}", applicationContext.getId()); IOHelper.close(applicationContext); } }
endpoint = CamelContextHelper.getMandatoryEndpoint(camelCtx, endpointUri); ServiceHelper.startServices(camelCtx, endpoint, consumer); ServiceHelper.stopAndShutdownServices(camelCtx, endpoint, consumer);
@Override public void afterPropertiesSet() throws Exception { StopWatch watch = new StopWatch(); super.afterPropertiesSet(); Boolean shutdownEager = CamelContextHelper.parseBoolean(getContext(), getShutdownEager()); if (shutdownEager != null) { LOG.debug("Using shutdownEager: {}", shutdownEager); getContext().setShutdownEager(shutdownEager); } LOG.debug("afterPropertiesSet() took {} millis", watch.stop()); }
protected CamelLogger createLogger() { return new CamelLogger(LoggerFactory.getLogger(TransactionErrorHandler.class), LoggingLevel.ERROR); }
public long timeTaken() { return watch.taken(); }
@Override protected void finished(Description description) { watch.stop(); }
/** * Asserts that the predicate returns the expected value on the exchange */ public static void assertPredicateDoesNotMatch(Predicate predicate, Exchange exchange) { try { PredicateAssertHelper.assertMatches(predicate, "Predicate should match: ", exchange); } catch (AssertionError e) { LOG.debug("Caught expected assertion error: " + e); } assertPredicate(predicate, exchange, false); }
public String toString() { return "MainRunner(" + name(main) + " " + Arrays.asList(getArgs()) + ")"; }
public TransactionTemplate getTransactionTemplate() { if (template == null) { ObjectHelper.notNull(transactionManager, "transactionManager"); template = new TransactionTemplate(transactionManager); if (propagationBehaviorName != null) { template.setPropagationBehaviorName(propagationBehaviorName); } } return template; }
/** * Apply additional configuration to the context */ protected void configure(SpringCamelContext ctx) { try { // allow any custom configuration, such as when running in camel-spring-boot if (applicationContext.containsBean("xmlCamelContextConfigurer")) { XmlCamelContextConfigurer configurer = applicationContext.getBean("xmlCamelContextConfigurer", XmlCamelContextConfigurer.class); if (configurer != null) { configurer.configure(applicationContext, ctx); } } } catch (Exception e) { // error during configuration throw ObjectHelper.wrapRuntimeCamelException(e); } }
/** * Asserts that the predicate returns the expected value on the exchange */ public static void assertPredicateDoesNotMatch(Predicate predicate, Exchange exchange) { try { PredicateAssertHelper.assertMatches(predicate, "Predicate should match: ", exchange); } catch (AssertionError e) { LOG.debug("Caught expected assertion error: " + e); } assertPredicate(predicate, exchange, false); }
public EventConsumer createConsumer(Processor processor) throws Exception { ObjectHelper.notNull(applicationContext, "applicationContext"); EventConsumer answer = new EventConsumer(this, processor); configureConsumer(answer); return answer; }
@Override public void start() { try { setupRoutes(); } catch (Exception e) { throw wrapRuntimeCamelException(e); } // when the routes are setup we need to start the Camel context context.start(); }
/** * Asserts that the predicate returns the expected value on the exchange */ public static boolean assertPredicate(final Predicate predicate, Exchange exchange, boolean expected) { if (expected) { PredicateAssertHelper.assertMatches(predicate, "Predicate failed: ", exchange); } boolean value = predicate.matches(exchange); LOG.debug("Evaluated predicate: " + predicate + " on exchange: " + exchange + " result: " + value); assertEquals("Predicate: " + predicate + " on Exchange: " + exchange, expected, value); return value; }
/** * Asserts that the predicate returns the expected value on the exchange */ public static boolean assertPredicate(final Predicate predicate, Exchange exchange, boolean expected) { if (expected) { PredicateAssertHelper.assertMatches(predicate, "Predicate failed: ", exchange); } boolean value = predicate.matches(exchange); LOG.debug("Evaluated predicate: " + predicate + " on exchange: " + exchange + " result: " + value); assertEquals("Predicate: " + predicate + " on Exchange: " + exchange, expected, value); return value; }