I have several bundles (A, B, and C) deployed to an OSGi container, each containing a CamelContext
and some routes. I have another bundle (M) with a CamelCont
I dont think this is possible using InterceptorStrategy
since that expects it is running in the same camel context. The only ways I am aware of working across multiple contexts is using the VM endpoint (which is obviously limited to the same JVM), however in this case you would probably be better utilising JMS, JMX or something similar.
JMS
Create an InterceptorStrategy
for each camel context in A, B & C
that publishes your messages to M
intercept().bean(transformForMonitoring).to("jms:queue:monitoring");
from("whatever:endpoint")
.process(myProcessor)
.to("target:endpoint");
You could also use the vm
component on the intercept()
if you dont want the overhead of JMS, however this limits your monitoring component to a single JVM.
JMX
This is a bit more complicated, but the basic idea is to tell the camel context to publish MBeans for A, B & C
<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
<jmxAgent id="agent" mbeanObjectDomainName="your.domain.name"/>
...
</camelContext>
and then have M
connect to the JVM MBean Server and utilise something like NotificationListener to react to the Exchanges.
One of the possibility is define a custom Tracer in Bundle 'M' and export it as osgi service.
In bundle A,B,C define osgi-reference to exported Tracer bean
Use camel JMX to enable trace.
This will result changes in bundle A,B,C but it will be minimal and it will also give ability to integrate and configure tracing (intercepting)
I have not tried this myself, but hth
Either use Spring-DM, or better transform all your spring xml based routes to blueprint ones. This is the best supported way of using XML based Routes in Karaf/Osgi.