3 Replies Latest reply on Dec 16, 2011 8:38 AM by Ravi Challapalli

    camel-cache cacheManagerFactory option fails - camel 2.8.3

    Ravi Challapalli Newbie

      Hi,

       

       

       

      I get the following exception when configuring ehcache using cacheManagerFactory.

       

      Versions: Camel/camel-cache/blueprint 2.8.3, servicemix-4.4.1-fuse-01-06

       

      I tried providing the factory reference the following ways

       

      cacheManagerFactory=com.test.MyCacheFactory (extends org...CacheManagerFactory)

      &

      cacheManagerFactory=ehCacheFactory

      &

      cacheManagerFactory=#ehCacheFactory

       

      any ways get the below exception.

       

      no setter for cacheManagerFactory.

       

      org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint: cache://configCache?cacheManagerFactory=%23ehCacheFactory due to: Could not find a suitable setter for property: cacheManagerFactory as there isn't a setter method with same type: java.lang.String nor type conversion possible: No type converter available to convert from type: java.lang.String to the required type: org.apache.camel.component.cache.CacheManagerFactory with value #ehCacheFactory

       

      Please help.

       

      Thanks in advance.

      ravi

        • 1. Re: camel-cache cacheManagerFactory option fails - camel 2.8.3
          Claus Ibsen Master

          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
            Willem Jiang Master

            Hi,

             

            Did you define the CacheManagerFactory in the blueprint context?

             

            Willem

            • 3. Re: camel-cache cacheManagerFactory option fails - camel 2.8.3
              Ravi Challapalli Newbie

              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