1

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.

Ashish Mishra
  • 169
  • 16
  • 1
    could you please provide code sample where you are importing context files. As I know you can only share objects between osgi bundles but not context files – Aliaksei Bulhak Sep 02 '16 at 07:01
  • Why don't you keep separate contexts and put all shared beans into their own bundle? – Alessandro Da Rugna Sep 02 '16 at 15:15
  • It's my requirement and architecture design. I can't change it now because there is huge impact on existing services. That's reason wanted to modified the camel-context id at runtime. – Ashish Mishra Sep 05 '16 at 11:07

1 Answers1

3

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

Claus Ibsen
  • 56,060
  • 7
  • 50
  • 65