I have defined a Camel context with a route creating and populating a cache.
This camel context is included into a web application deployed on Tomcat.

The route creating and populating the cache is fired at startup using a Quartz 
endpoint. Everything works fine.

Now I want to query that cache from another web application deployed to the 
same Tomcat server (i.e. same JVM for the two webapps), using a dedicated Camel 
route.

The problem is that the CacheManager instantiated by Camel is a singleton 
within the scope of the classloader and, since Servlet API reverses the 
standard classloading hierarchy, the two webapps each create their own 
CacheManager, so they cannot share the cache.

I am using Camel 2.6.0.

I have found an ugly workaround, which is to delete all the jars from the 
WEB-INF/lib directories and copy them into Tomcat lib directory.

Another workaround that I am trying is to query the cache through a vm: 
endpoint from one Camel context to the other, like this:

Context A:

from("wherever").to("vm:queryCache")


Context B:

from("vm:queryCache").to("cache://myCache")

Can you suggest other ways of having the webapps sharing the cache?

Is it possible to override Ehcache configuration with camel 2.6.0?

Thanks

Alberto

--
View this message in context: 
http://camel.465427.n5.nabble.com/two-webapps-on-Tomcat-sharing-cache-through-Camel-tp4598504p4598504.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to