11 Replies Latest reply on Jul 28, 2011 6:31 AM by Pete Muir

    Infinispan caching in portlets within same portal

    Megha Shah Newbie

      Hi,

      I have a portal application, which hosts several portlets within it.

      According to my business scenario, we need to store certain user related information within a cache to enable seemless usage within the application.

      For this I have been using Jboss Cache and POJO Cache in JBoss AS 4.0.5 and JBoss Portal 2.4

       

      Now we are migrating to JBoss 6.x with Gatein 3.1

      I am also using Infinispan for caching with the above new setup.

       

      From what I have understood of Infinispan is that it supports caching only in clustered environments ? Correct me if I am wrong.

       

      What led me to the above conclusion is when I tried testing the Infinispan cache as a standalone, it works fine. I am able to set and retrieve values from the cache. But when I try the same within different modules (portlets) it does'nt work. The cache object returned is NULL.

       

      Here is the sample code.

      ===== 1st Portlet======
      
      
      SubscriberCache subscriberCache = SubscriberCache.getSubscriberCacheInstance();
       Cache cache=subscriberCache.startCache();
       System.out.println("cache :::"+cache);
       //log.info(subscriberID + "~Creating the instance of SubscriberInfo");
       SubscriberInfo subInfo = new SubscriberInfo();
       //log.info(subscriberID + "~Getting the Object from cache instance");
       subInfo = (SubscriberInfo)cache.get("100000000");
       System.out.println("SubscriberInfo:::"+subInfo.getMessage()); 
      
      
      ==== 2nd Portlet====
      
      
      
      
         SubscriberCache subscriberCache = SubscriberCache.getSubscriberCacheInstance();
       Cache cache=subscriberCache.startCache();
       //log.info(subscriberID + "~Creating the instance of SubscriberInfo");
       SubscriberInfo subInfo = new SubscriberInfo();
       //log.info(subscriberID + "~Getting the Object from cache instance");
       System.out.println("Cache Key value: " + cache.get("100000000"));
       subInfo = (SubscriberInfo)cache.get("100000000");
       System.out.println("SubscriberInfo:::"+subInfo.getMessage());
      
      
        
      
      
      
      

      When I access my 2nd portlet, the line "System.out.println("Cache Key value: " + cache.get("100000000"));" reads "Cache Key value: NULL"

       

      Any idea where am I going wrong or missing something ?

       

      Thanks in advance

      Megha