Search code examples
apache-camelosgijbossfusespring-dsl

How to dynamically setting CamelContext ID in Spring DSL?


How to set camelContext id dynamically in the spring DSL? Consider my scenario like this,

Bundle A : having camelContext where I set id attribute say simple-ctx. This bundle has some other utilities beans which is used in some other bundle.

Bundle B : importing A context file where I defined the camel context. in B I have defined B specific routes

Bundle C : importing A context file where I defined the camel context. in C I have defined C specific routes

Now, bundle B and C is depends on Bundle A. Now, if I do context-list command it lists simple-ctx. Which means Bundle B and C has same camelContext id. I wanted to achieve that id should like simple-ctx-B and simple-ctx-C without defining the camelContext in B or C.

Appreciate your suggestion and feedback.


Solution

  • This is not possible. The id is a fixed value. However the JMX naming can be take in dynamic values such as counters, bundle ids, etc.

    http://camel.apache.org/camel-jmx.html

    It sounds as if you want A to have a naming where the prefix is the name of its parent?

    Also instead of having camelContext in all the bundles. You can have routes in A instead so these routes are included in the same camelContext as from B or C: http://camel.apache.org/how-do-i-import-routes-from-other-xml-files.html