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; }
/** * 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); } }
@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(); }
public void onApplicationEvent(ApplicationEvent event) { Exchange exchange = createExchange(); exchange.getIn().setBody(event); try { getLoadBalancer().process(exchange); } catch (Exception e) { throw wrapRuntimeCamelException(e); } }
@Override public void stop() { if (!isStopping() && !isStopped()) { try { super.stop(); } catch (Exception e) { throw wrapRuntimeCamelException(e); } } else { // ignore as Camel is already stopped LOG.trace("Ignoring stop() as Camel is already stopped"); } }
@Override public void start() { // for example from unit testing we want to start Camel later (manually) if (Boolean.TRUE.equals(NO_START.get())) { LOG.trace("Ignoring start() as NO_START is false"); return; } if (!isStarted() && !isStarting()) { try { StopWatch watch = new StopWatch(); super.start(); LOG.debug("start() took {} millis", watch.stop()); } catch (Exception e) { throw wrapRuntimeCamelException(e); } } else { // ignore as Camel is already started LOG.trace("Ignoring start() as Camel is already started"); } }
protected void doInTransactionWithoutResult(TransactionStatus status) { // wrapper exception to throw if the exchange failed // IMPORTANT: Must be a runtime exception to let Spring regard it as to do "rollback" RuntimeException rce; // and now let process the exchange by the error handler processByErrorHandler(exchange); // after handling and still an exception or marked as rollback only then rollback if (exchange.getException() != null || exchange.isRollbackOnly()) { // wrap exception in transacted exception if (exchange.getException() != null) { rce = ObjectHelper.wrapRuntimeCamelException(exchange.getException()); } else { // create dummy exception to force spring transaction manager to rollback rce = new TransactionRollbackException(); } if (!status.isRollbackOnly()) { status.setRollbackOnly(); } // throw runtime exception to force rollback (which works best to rollback with Spring transaction manager) if (log.isTraceEnabled()) { log.trace("Throwing runtime exception to force transaction to rollback on {}", transactionTemplate.getName()); } throw rce; } } });
public void onInit(Route route) { try { doOnInit(route); } catch (Exception e) { throw ObjectHelper.wrapRuntimeCamelException(e); } }
@Override public void onRemove(Route route) { try { // stop and un-schedule jobs doStop(); } catch (Exception e) { throw ObjectHelper.wrapRuntimeCamelException(e); } }
public HttpClientPipelineFactory(NettyHttpProducer nettyProducer) { this.producer = nettyProducer; try { this.sslContext = createSSLContext(producer); } catch (Exception e) { throw ObjectHelper.wrapRuntimeCamelException(e); } if (sslContext != null) { LOG.info("Created SslContext {}", sslContext); } }
@Override public void onRemove(Route route) { try { // stop and un-schedule jobs doStop(); } catch (Exception e) { throw ObjectHelper.wrapRuntimeCamelException(e); } }
@Deprecated public DefaultServerInitializerFactory(NettyServerBootstrapConfiguration configuration) { this.consumer = null; try { this.sslContext = createSSLContext(null, configuration); } catch (Exception e) { throw ObjectHelper.wrapRuntimeCamelException(e); } if (sslContext != null) { LOG.info("Created SslContext {}", sslContext); } }
public void onInit(Route route) { try { doOnInit(route); } catch (Exception e) { throw ObjectHelper.wrapRuntimeCamelException(e); } }
public void onInit(Route route) { try { doOnInit(route); } catch (Exception e) { throw ObjectHelper.wrapRuntimeCamelException(e); } }
public String dumpStatisticsAsJsonTimeUnitSeconds() { ObjectWriter writer = secondsMapper.writer(); if (isPrettyPrint()) { writer = writer.withDefaultPrettyPrinter(); } try { return writer.writeValueAsString(getMetricsRegistry()); } catch (JsonProcessingException e) { throw ObjectHelper.wrapRuntimeCamelException(e); } }
public String dumpStatisticsAsJsonTimeUnitSeconds() { ObjectWriter writer = secondsMapper.writer(); if (isPrettyPrint()) { writer = writer.withDefaultPrettyPrinter(); } try { return writer.writeValueAsString(getMeterRegistry()); } catch (JsonProcessingException e) { throw ObjectHelper.wrapRuntimeCamelException(e); } }
@Override public void unscheduleTask() { if (trigger != null) { LOG.debug("Unscheduling trigger: {}", trigger.getKey()); try { quartzScheduler.unscheduleJob(trigger.getKey()); } catch (SchedulerException e) { throw ObjectHelper.wrapRuntimeCamelException(e); } } }
public DefaultServerPipelineFactory(NettyConsumer consumer) { this.consumer = consumer; try { this.sslContext = createSSLContext(consumer.getContext(), consumer.getConfiguration()); } catch (Exception e) { throw ObjectHelper.wrapRuntimeCamelException(e); } if (sslContext != null) { LOG.info("Created SslContext {}", sslContext); } }
protected String resolvePropertyPlaceholders(String str) { try { if (getCamelContext() != null) { return getCamelContext().resolvePropertyPlaceholders(str); } else { return str; } } catch (Exception ex) { throw ObjectHelper.wrapRuntimeCamelException(ex); } }
protected String resolvePropertyPlaceholders(String str) { try { if (getCamelContext() != null) { return getCamelContext().resolvePropertyPlaceholders(str); } else { return str; } } catch (Exception ex) { throw ObjectHelper.wrapRuntimeCamelException(ex); } }