Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-8914

Unable to shutdown endpoint when intercepted with interceptSendToEndpoint



    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.15.2
    • Fix Version/s: 2.15.3, 2.16.0
    • Component/s: None
    • Labels:
    • Estimated Complexity:


      I'm facing an issue with the version of camel 2.15.2

      I have a component that create an endpoint.

      This endpoint override the shutdown and doShutdown method so we can log values at shutdown time.

      But when this endpoint is intercept with the interceptSendToEnpoint method the shutdown is not called.

      Here is an example of code to reproduce:

      the Component:
      public class CustomComponent extends DefaultComponent {

      protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception

      { return new CustomEndpoint(); }


      the Endpoint:
      public class CustomEndpoint extends DefaultEndpoint {

      public Producer createProducer() throws Exception {
      return new DefaultProducer(this) {
      public void process(Exchange exchange) throws Exception

      { log.info(exchange.getExchangeId()); }


      public Consumer createConsumer(Processor processor) throws Exception

      { return null; }

      public boolean isSingleton()

      { return false; }

      public void shutdown() throws Exception

      { super.shutdown(); System.out.println("SHUTDOWN"); }

      protected void doShutdown() throws Exception

      { super.doShutdown(); System.out.println("do SHUTDOWN"); }

      protected String createEndpointUri()

      { return "myEndpoint"; }


      the route:
      public class MyRoute extends RouteBuilder {

      public void configure() {

      { getContext().addComponent("myEndpoint", new CustomComponent()); }

      catch (Exception e)

      { e.printStackTrace(); }


      from("direct:murex").routeId("Trade Repository Route")

      When there is an interceptor the shutdown on the endpoint is not called, when there is no interceptor the shutdown is called.

      After some debugging I noticed that in the DefaultCamelContext at the shutdown time the shutdown is called on the list of endpoints, when there is an interceptor the list do not contain the CustomEnpoint but only the Interceptor, and because the interceptor does not implement ShutdownableAware the shutdown is not propagate to the underlying endpoint (here the CustomEndpoint)

      Without the interceptor the CustomEndpoint appears in the list and the shutdown method is called.




            • Assignee:
              davsclaus Claus Ibsen
              gterral Terral Guillaume
            • Votes:
              0 Vote for this issue
              2 Start watching this issue


              • Created: