You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by ncasaux <ni...@soprasteria.com> on 2015/11/27 18:11:38 UTC

camel cache configurationFile

Hello,

I'm trying to use the camel cache component with a configuration file as
described in the camel cache component:

<bean id="TestCache2"
class="org.apache.camel.component.cache.CacheComponent">
	<property name="configurationFile"
value="file:D:\\Tools\\apache-servicemix-6.0.1\\etc\\ehcache.xml"/> 
</bean>

However, it's not working, as I always get the message when I update the
bundle:
net.sf.ehcache - 2.9.1 | No configuration found. Configuring ehcache from
ehcache-failsafe.xml  found in the classpath:
bundle://242.0:1/ehcache-failsafe.xml

Ideally, I would like to use a value like "[karaf_etc]\ehcache.xml"...

Am I doing something wrong ? Thanks in advance for your feedback.






--
View this message in context: http://camel.465427.n5.nabble.com/camel-cache-configurationFile-tp5774492.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: camel cache configurationFile

Posted by vassilis <2b...@gmail.com>.
Hi,

Just solved the same issue without having a dependency on the Karaf
installation path:

You have to include the ehcache.xml file in your bundle jar file. E.g. you
may have it as

<http://camel.465427.n5.nabble.com/file/n5791855/ehcache.png> 

and point to it:

	<bean id="cache" class="org.apache.camel.component.cache.CacheComponent">
 *   	<property name="configurationFile"
value="classpath:com/edmi/certificates/management/meters/routes/ehcache.xml"
/>*
  	</bean>

In any case to include it in a different way you can configure your maven
bundle plugin to do so.

------------Details---------------

blueprint.xml:

	<bean id="ehCacheManagementService"
class="net.sf.ehcache.management.ManagementService"
		init-method="init" activation="eager">
		<argument>
			<bean class="net.sf.ehcache.CacheManager" factory-method="getInstance" />
		</argument>
		<argument>
			<bean class="org.springframework.jmx.support.JmxUtils"
				factory-method="locateMBeanServer" />
		</argument>
		<argument value="true" />
		<argument value="true" />
		<argument value="true" />
		<argument value="true" />
	</bean>
	
	<bean id="cache" class="org.apache.camel.component.cache.CacheComponent">
    	<property name="configurationFile"
value="classpath:com/edmi/certificates/management/meters/routes/ehcache.xml"
/>
  	</bean>

ehcache.xml:

<?xml version="1.0" encoding="UTF-8"?>
<ehcache>

<defaultCache maxElementsInMemory="1000" eternal="false"
timeToIdleSeconds="120" timeToLiveSeconds="200" />    

<cache
    name="initAndGetLineCounterForKey"
    timeToIdleSeconds="0"
    timeToLiveSeconds="0"
    overflowToDisk="false"
    diskPersistent="false"
    memoryStoreEvictionPolicy="LFU" 
    transactionalMode="off"
    maxElementsInMemory="10000"
/>
</ehcache>



--
View this message in context: http://camel.465427.n5.nabble.com/camel-cache-configurationFile-tp5774492p5791855.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: camel cache configurationFile

Posted by ncasaux <ni...@soprasteria.com>.
For the future, here what has been done to solve my issue:

<blueprint>
xmlns:ext="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.0.0"

  <ext:property-placeholder placeholder-prefix="$[" placeholder-suffix="]"
/>

  <bean id="cache" class="org.apache.camel.component.cache.CacheComponent">
    <property name="configurationFile"
value="file:$[karaf.base]/etc/ehcache.xml" />
  </bean>

</blueprint>

For monitoring the cache, I set the attribute monitoring="on" in the
ehcache.xml.



--
View this message in context: http://camel.465427.n5.nabble.com/camel-cache-configurationFile-tp5774492p5775600.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: camel cache configurationFile

Posted by ncasaux <ni...@soprasteria.com>.
I just noticed something I can't understand:

In my bean, I have also this piece of code for monitoring my cache
configuration:

<bean id="ehCacheManagementService"
class="net.sf.ehcache.management.ManagementService" init-method="init"
lazy-init="false">
  <constructor-arg>
    <bean class="net.sf.ehcache.CacheManager" factory-method="getInstance"/>
  </constructor-arg>
  <constructor-arg>
    <bean class="org.springframework.jmx.support.JmxUtils"
factory-method="locateMBeanServer"/>
  </constructor-arg>
  <constructor-arg value="true"/>
  <constructor-arg value="true"/>
  <constructor-arg value="true"/>
  <constructor-arg value="true"/>
</bean>

During my bundle start, I can see in the logs:

2015-11-30 11:16:01,486 | WARN  | xtenderThread-30 | ConfigurationFactory            
| 242 - net.sf.ehcache - 2.9.1 | No configuration found

2015-11-30 11:16:01,558 | INFO  | xtenderThread-30 |
DefaultCacheManagerFactory       | 243 - org.apache.camel.camel-cache -
2.15.3 | Creating CacheManager usin
g camel-cache configuration:
file:D:\\Tools\\apache-servicemix-6.0.1-DUPLICATE\\etc\\ehcache.xml

However, when I look at the cache configuration created, the values are not
the ones from my ehcache.xml



When I remove the bean "ehCacheManagementService" and I restart the bundle,
I can see in the logs:
:

2015-11-30 11:19:26,318 | INFO  | xtenderThread-32 |
DefaultCacheManagerFactory       | 243 - org.apache.camel.camel-cache -
2.15.3 | Creating CacheManager usin
g camel-cache configuration:
file:D:\\Tools\\apache-servicemix-6.0.1-DUPLICATE\\etc\\ehcache.xml

So, no more warning "No configuration found", but I can't check if my cache
configuration is OK.


Is that possible that the monitoring bean I use prevent my cache from being
created as per my ehcache.xml file ?




--
View this message in context: http://camel.465427.n5.nabble.com/camel-cache-configurationFile-tp5774492p5774555.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: camel cache configurationFile

Posted by Minh Tran <da...@gmail.com>.
Is there an exception/stacktrace with the error? That might give you a clue as to what the problem is.

The only thing I can think of is perhaps your ehcache.xml doesn’t contain the TestCache2 region defined in there.

> On 30 Nov 2015, at 8:06 PM, ncasaux <ni...@soprasteria.com> wrote:
> 
> Thanks for your suggestion.
> 
> However, I did as you recommand : 
> 
> <bean id="cache" class="org.apache.camel.component.cache.CacheComponent">
>    <property name="configurationFile"
> value="file:D:\\Tools\\apache-servicemix-6.0.1\\etc\\ehcache.xml"/>    
> </bean>
> 
> but I still get the "No configuration found" when I update the bundle.
> 
> 
> 
> --
> View this message in context: http://camel.465427.n5.nabble.com/camel-cache-configurationFile-tp5774492p5774552.html
> Sent from the Camel - Users mailing list archive at Nabble.com.


Re: camel cache configurationFile

Posted by ncasaux <ni...@soprasteria.com>.
Thanks for your suggestion.

However, I did as you recommand : 

<bean id="cache" class="org.apache.camel.component.cache.CacheComponent">
    <property name="configurationFile"
value="file:D:\\Tools\\apache-servicemix-6.0.1\\etc\\ehcache.xml"/>    
</bean>

but I still get the "No configuration found" when I update the bundle.



--
View this message in context: http://camel.465427.n5.nabble.com/camel-cache-configurationFile-tp5774492p5774552.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: camel cache configurationFile

Posted by Minh Tran <da...@gmail.com>.
Hi

That TestCache2 in your uri is not the name of the bean, it’s the name of the cache. 

The easiest way to fix your problem is to set the id your spring bean from “TestCache2" to “cache” in your xml earlier

> On 30 Nov 2015, at 7:32 PM, ncasaux <ni...@soprasteria.com> wrote:
> 
> Hello,
> 
> In my route, I'm using this URI, which seems OK with the bean to me:
> 
> .to("cache://TestCache2")
> 
> 
> 
> --
> View this message in context: http://camel.465427.n5.nabble.com/camel-cache-configurationFile-tp5774492p5774549.html
> Sent from the Camel - Users mailing list archive at Nabble.com.


Re: camel cache configurationFile

Posted by ncasaux <ni...@soprasteria.com>.
Hello,

In my route, I'm using this URI, which seems OK with the bean to me:

.to("cache://TestCache2")



--
View this message in context: http://camel.465427.n5.nabble.com/camel-cache-configurationFile-tp5774492p5774549.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: camel cache configurationFile

Posted by Minh Tran <da...@gmail.com>.
Does your uri look something like “cache:blah”? It should be whatever bean name you’ve chosen. In your example it is “TestCache2:blah"

Easier just to name your bean “cache” to override the default.

> On 28 Nov 2015, at 4:11 AM, ncasaux <ni...@soprasteria.com> wrote:
> 
> Hello,
> 
> I'm trying to use the camel cache component with a configuration file as
> described in the camel cache component:
> 
> <bean id="TestCache2"
> class="org.apache.camel.component.cache.CacheComponent">
> 	<property name="configurationFile"
> value="file:D:\\Tools\\apache-servicemix-6.0.1\\etc\\ehcache.xml"/> 
> </bean>
> 
> However, it's not working, as I always get the message when I update the
> bundle:
> net.sf.ehcache - 2.9.1 | No configuration found. Configuring ehcache from
> ehcache-failsafe.xml  found in the classpath:
> bundle://242.0:1/ehcache-failsafe.xml
> 
> Ideally, I would like to use a value like "[karaf_etc]\ehcache.xml"...
> 
> Am I doing something wrong ? Thanks in advance for your feedback.
> 
> 
> 
> 
> 
> 
> --
> View this message in context: http://camel.465427.n5.nabble.com/camel-cache-configurationFile-tp5774492.html
> Sent from the Camel - Users mailing list archive at Nabble.com.