public void createRouteToDeliverImpexToHotfolder(final String inputQueue, final String outputDest)
      throws Exception {

    final RouteBuilder builder =
        new RouteBuilder() {
          public void configure() {
            from(inputQueue).to(outputDest);
          }
        };
    builder
        .onException(Throwable.class)
        .maximumRedeliveries(2)
        .maximumRedeliveryDelay(1000)
        .multicast()
        .to(DELIVERY_DEAD_LETTER_QUEUE)
        .process(
            new Processor() {
              @Override
              public void process(Exchange exchange) throws Exception {
                Throwable caused = exchange.getProperty(Exchange.EXCEPTION_CAUGHT, Throwable.class);
                StringWriter sw = new StringWriter();
                caused.printStackTrace(new PrintWriter(sw));
                exchange.getIn().setBody(sw.toString());
                exchange.getIn().setHeader("Subject", "Delivery impex file failed");
                exchange.getContext().createProducerTemplate().send(SEND_EMAIL_QUEUE, exchange);
              }
            });

    context.addRoutes(builder);
  }
  public void createRouteToSendEmails(final String fromQueue, final String toQueue)
      throws Exception {

    final RouteBuilder builder =
        new RouteBuilder() {
          public void configure() {
            from(fromQueue).to(toQueue);
          }
        };
    builder.setErrorHandlerBuilder(new DeadLetterChannelBuilder(SEND_EMAIL_DEAD_LETTER_QUEUE));
    context.addRoutes(builder);
  }
  private void configureCamelRoute() {
    LOGGER.trace("ENTERING: configureCamelRoute");

    // Must have a directory to be monitored to be able to configure the Camel route.
    if (StringUtils.isEmpty(monitoredDirectory)) {
      LOGGER.debug("Cannot setup camel route - must specify a directory to be monitored");
      return;
    }

    if (StringUtils.isEmpty(directive)) {
      LOGGER.debug(
          "Cannot setup camel route - must specify a directive for the directory to be monitored");
      return;
    }

    RouteBuilder routeBuilder =
        new RouteBuilder() {
          @Override
          public void configure() throws Exception {
            String inbox = "file:" + monitoredDirectory + "?moveFailed=.errors";
            if (copyIngestedFiles) {
              inbox += "&move=.ingested";
            } else {
              inbox += "&delete=true";
            }
            LOGGER.debug("inbox = " + inbox);

            from(inbox)
                .setHeader(Request.OPERATION, constant("create"))
                .setHeader(Request.DIRECTIVE, constant(directive))
                .setHeader(Request.CONTENT_URI, constant(""))
                .to("content:framework");
          }
        };

    try {
      // Add the routes that will be built by the RouteBuilder class above
      // to this CamelContext.
      // The addRoutes() method will instantiate the RouteBuilder class above,
      // and start the routes (only) if the camelContext has already been started.
      camelContext.addRoutes(routeBuilder);

      // Save the routes created by RouteBuilder so that they can be
      // stopped and removed later if the route(s) are modified by the
      // administrator or this ContentDirectoryMonitor is deleted.
      this.routeCollection = routeBuilder.getRouteCollection().getRoutes();

      // Start route that was just added.
      // If the route was just added for the first time, i.e., this not a bundle
      // restart, then this method will do nothing since the addRoutes() above
      // already started the route. But for bundle (or system) restart this call
      // is needed since the addRoutes() for whatever reason did not start the route.
      startRoutes();

      if (LOGGER.isDebugEnabled()) {
        dumpCamelContext("after configureCamelRoute()");
      }
    } catch (Exception e) {
      LOGGER.error(
          "Unable to configure Camel route - this Content Directory Monitor will be unusable", e);
    }

    LOGGER.trace("EXITING: configureCamelRoute");
  }