@Test
  public void shouldDLQOrginalHandler() throws Exception {

    ModelCamelContext context = new DefaultCamelContext();
    context.setTracing(true);
    ProducerTemplate pt = context.createProducerTemplate();
    context.addRoutes(
        new RouteBuilder() {

          @Override
          public void configure() throws Exception {
            // will use original
            ErrorHandlerBuilder a =
                deadLetterChannel("seda:dead")
                    .maximumRedeliveries(1)
                    .redeliveryDelay(300)
                    .logStackTrace(false)
                    .useOriginalMessage()
                    .logHandled(false);

            from("seda:start")
                .errorHandler(a)
                .log(LoggingLevel.INFO, "myCamel", "==== ${body}")
                .bean(SampleErrorBean.class)
                .bean(ChangeBody.class)
                .bean(ErrorBean.class)
                .bean(SampleErrorBean.class)
                .transform(constant("ok"));
            from("seda:dead")
                .bean(FailureBean.class)
                .process(
                    exchange -> {
                      counterA.incrementAndGet();
                      Throwable e =
                          exchange.getProperty(Exchange.EXCEPTION_CAUGHT, Throwable.class);
                      log.info("+++  properties :  {}", exchange.getProperties());
                      log.info("+++  body :  {}", exchange.getIn().getBody());
                      log.info("+++  headers  :  {}", exchange.getIn().getHeaders());
                      log.info("+++  exception Processor : {}", e);
                      log.info(
                          "+++ counterA :  {} , header : {}",
                          counterA.get(),
                          exchange.getProperty("CamelExceptionCaught"));
                    })
                .convertBodyTo(String.class)
                .bean(SampleErrorBean.class);
          }
        });
    context.start();
    String result = (String) pt.requestBody("seda:start", "test");
    Assertions.assertThat(result).isEqualTo("test");
    Thread.sleep(3000);
  }
  @Test
  public void shouldDLQHandler() throws Exception {

    ModelCamelContext context = new DefaultCamelContext();

    ProducerTemplate pt = context.createProducerTemplate();
    context.addRoutes(
        new RouteBuilder() {

          @Override
          public void configure() throws Exception {
            ErrorHandlerBuilder b =
                deadLetterChannel("direct:dead")
                    .maximumRedeliveries(3)
                    .redeliveryDelay(300)
                    .logStackTrace(true)
                    .logHandled(true);
            from("seda:start")
                .errorHandler(b)
                .log(LoggingLevel.INFO, "myCamel", "==== ${body}")
                .bean(SampleErrorBean.class)
                .bean(ChangeBody.class)
                .bean(ErrorBean.class)
                .bean(SampleErrorBean.class)
                .transform(constant("ok"));
            from("direct:dead")
                .bean(FailureBean.class)
                .process(new ErrorLogProcessor())
                .convertBodyTo(String.class)
                .bean(SampleErrorBean.class);
          }
        });
    context.start();
    String result = (String) pt.requestBody("seda:start", "test");
    Assertions.assertThat(result).isEqualTo("change  :: test");
    Thread.sleep(3000);
  }
  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");
  }