[JBoss JIRA] Created: (ISPN-1338) Using cache on a Singleton bean
by Vinicius Carvalho (JIRA)
Using cache on a Singleton bean
-------------------------------
Key: ISPN-1338
URL: https://issues.jboss.org/browse/ISPN-1338
Project: Infinispan
Issue Type: Enhancement
Components: CDI integration
Affects Versions: 5.0.0.FINAL, 5.0.0.CR8, 5.1.0.FINAL
Environment: infinispan-cdi 5.1.0-SNAPSHOT, jboss AS 7 (all libs packaged within ear)
Reporter: Vinicius Carvalho
Assignee: Manik Surtani
Priority: Optional
I'm trying to get the CDI examples to work on an app. so I've created this config:
@Produces
@ApplicationScoped
@OverrideDefault
public EmbeddedCacheManager getCacheManager() {
GlobalConfiguration gc = GlobalConfiguration.getClusteredDefault();
gc.fluent().transport().clusterName("shared-cache-cluster").addProperty("configurationFile", "jgroups-tcp.xml");
Configuration c = new Configuration().fluent().clustering().mode(CacheMode.REPL_ASYNC).build();
return new DefaultCacheManager(gc,c);
}
BTW, trying to use configuration and @Infinispan with this I get an error when CacheManager tries to get the cache, I've discussed it at http://community.jboss.org/thread/171005?tstart=0
Well, my scenario has 2 apps one on each node. So in one node I put a value in the distributed cache, and I expect to receive an event on the other node.
My problem is that the events for a cache are only hooked when the cache is first accessed (According to CacheManager:getAdvancedCache).
So, in my second ear, if there's no "warm-up" of the cache, the events do not get hooked and I don't get any notification.
So I tried to use a Singleton:
@Singleton
@Startup
public class CacheWarmupBean(){
@Inject Cache<String,String> cache;
@PostConstruct
void warm(){
cache.getCacheName();
}
}
Problem is that the bean gets started before the extension, and no target is found for the cache.
I wonder, is it possible to either warmup the cache on a different way or hook the events?
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira