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

camel-spring-boot - TypeConverter autoconfiguration leads to invalid shutdown sequence

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 2.16.1
    • 2.16.3, 2.17.0
    • camel-spring-boot
    • None

    Description

      When using autoconfiguration provided by the camel-spring-boot artifact, a TypeConverter bean is automatically registered into the Spring context:

      TypeConversionConfiguration.java
      @Bean
      TypeConverter typeConverter(CamelContext camelContext) {
          return camelContext.getTypeConverter();
      }
      

      The returned bean is an instance of DefaultTypeConverter, which in turn implements ServiceSupport and its method public void shutdown(). This method is infered as a destroy-method by Spring, and called during the shutdown of the ApplicationContext.

      As a consequence, the TypeConverter will be destroyed before the CamelContext, effectively preventing any type conversion support for the inflight messages that have still to be processed during the graceful shutdown period of Camel.

      AFAIK the simple fix would be to disable the destroy-method inference using @Bean(destroyMethod=""). This will let Camel have a chance to perform a clean shutdown in the right sequence.

      As a workaround, it is possible to entirely disable the registration of the type converter in Spring using the property
      camel.springboot.type-conversion = false

      Attachments

        1. CamelSpringBootShutdownTest.java
          4 kB
          Laurent Chiarello

        Issue Links

          Activity

            People

              davsclaus Claus Ibsen
              lchdev Laurent Chiarello
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: