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

camel.springboot.includeNonSingletons is not respected anymore: prototype Route Builders are always initialized.

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 4.3.0
    • 4.4.0
    • camel-spring-boot
    • None
    • Unknown

    Description

      Some time ago a new property was added to Apache Camel in CAMEL-10421, called "includeNonSingletons". It was configured via "camel.springboot.includeNonSingletons" property. Now it looks like `org.apache.camel.main.DefaultRoutesCollector.collectRoutesFromRegistry` finds all RouteBuilder in its `findByType(camelContext, RoutesBuilder.class);` method, regardless of whether they're prototypes or not by calling Spring's .`org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(@Nullable Class<T> type)`, which hard-codes `includeNonSingletons` to `true`.  

      In older Camel versions `org.apache.camel.spring.boot.RoutesCollector` class would run method `onApplicationEvent` and it would not touch prototypes due to this: "applicationContext.getBeansOfType(RoutesBuilder.class, configurationProperties.isIncludeNonSingletons(), true).values()".

      This issue causes our code to fail because we have a RouteBuilder prototype with only constructor to set URI and routeId dynamically for each builder. But we don't need Camel to do it automatically, because it does not know what to pass to that constructor.

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            davsclaus Claus Ibsen
            jpro.swt@gmail.com Yury Kartsev
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment