-
1. Re: camel-cache cacheManagerFactory option fails - camel 2.8.3
davsclaus Dec 16, 2011 12:14 AM (in response to rchallapalli)When you use #foo, then Camel is to lookup in the registry for a bean with that given id.
How have you define the CacheManagerFactory?
-
2. Re: camel-cache cacheManagerFactory option fails - camel 2.8.3
njiang Dec 16, 2011 2:57 AM (in response to rchallapalli)Hi,
Did you define the CacheManagerFactory in the blueprint context?
Willem
-
3. Re: camel-cache cacheManagerFactory option fails - camel 2.8.3
rchallapalli Dec 16, 2011 8:38 AM (in response to davsclaus)Hi Claus,
I have a test case invoking the cache endpoint where I had just created a local object of the CacheManagerFactory and provided to he cache configuration so it failed. Apologies for this,.. I am not aware how to provide a bean ref in a test case. Will be great if you can advise.
This worked when I actually deployed the camel routes into servicemix as I had declared the factory bean in blueprint context.
..........
I am not a design guru but have something to say regarding the cache component.
From my last projects what I allways used a cache (a custom built with some periodic refresh strategy) for is to store frequently accessed configurations or small data from database, LDAP or property files and all of them are key value/object pairs and to use them in conjunction with the incomming message and do some processing.
Suppose if I want a value from the cache, in Camel, I have to set two headers (key, operation) and invoke to("cache://...") which overwrites the existing exchange body. Before running an example what I actuall expected, looking at the usage, is that the value from cache will be populated in the header with the given key so that I can use it in processing the message. Now to do the same I have to do the below
from(...).
.setHeader(CacheConstants.CACHE_OPERATION, constant(CacheConstants.CACHE_OPERATION_GET))
.setHeader(CacheConstants.CACHE_KEY, constant("sender_id"))
.enrich("cache://configCache", cacheValueAggregationStrategy)
.process(...)
cacheValueAggregationStrategy is a been which populates the obtained value from cache in my current exchange's header.
public class CacheValueAggregationStrategy implements AggregationStrategy {
@Override
public Exchange aggregate(Exchange exchange, Exchange otherExchange) {
String key = exchange.getIn().getHeader(CacheConstants.CACHE_KEY, String.class);
exchange.getIn().setHeader(key, otherExchange.getIn().getBody(String.class));
return exchange;
}
Too lengthy isn't it?
And I have around 10 configurations to pull from the cache in such a way for processing the message.
a confing like .to("cache://myCache?key=mykey&operation=get") would have been great.
more flexible would be
.to("cache://configCache?key=mykey&operation=get&addAsHeader<or Property>=true").process(...)
Excuse for the lenghty post.
And your webinar yesterday was great though very basic.
Thanks & Best Regards,
ravi