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

Camel-CDI adds every RouteBuilder instance it can find to Camel context



    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 2.19.0
    • camel-cdi
    • None
    • Wildfly 10 with wildfly-camel extension

    • Unknown


      Camel-CDI will find every class in a deployment which extends RouteBuilder and automatically add them to the context. This is a major issue for me as I usually wants to instantiate my RouteBuilders programatically setting various parameters, with CDI support.

      This behaviour was introduced with https://github.com/apache/camel/commit/0421c24dfcf992f3296ed746469771e3800200e3 from antonin.stefanutti and we had a good discussion about the issue on his github project in https://github.com/astefanutti/camel-cdi/issues/12 but never came up with a good solution for it. I have patched camel-cdi to use a marker annotation @DoNotAddToCamelContext to work around it but I don't want to have to patch every release I use..

      I understand the logic why Camel-CDI finds and add every RouteBuilder class, even though I don't agree that it is a good idea but it could very well be the default behavior as long as it is possible to override it.

      What I would like is a discussion on how this could be made configurable. I'm thinking about if there could be an annotation like @CamelContextStartup(false) or maybe even a more general @CamelContextConfig(autostart=false) if there are other things that should be configurable.




            antonin.stefanutti Antonin Stefanutti
            sverker Sverker Abrahamsson
            0 Vote for this issue
            4 Start watching this issue