shillner
shillner

Reputation: 1846

Getting pre-configured cache from cache container configured under infinispan wildfly subsystem

I'm pretty confused about the infinispan subsystem under Wildfly and am not able to get a pre-configured cache from an existing cache container. To visualize the problem I've created a minimal sample project shared on Github: infinispan-wildfly-test

The test setup creates a cache container (TEST) with two caches (x,y), setting x to be the default. When I now get the EmbeddedCacheManager through resource lookup I get the container I'm expecting:

@Resource(lookup = "java:jboss/infinispan/container/TEST")
private EmbeddedCacheManager cacheManager;

But then, when trying to get a Cache (x or y) I always get a freshly created one whose configuration does not match the one that I have created using the CLI, the cache is totally unconfigured!

The point is I can be sure that the EmbeddedCacheManager is the correct container since it delivers me Cache x as the default one (but unconfigured) but what am I missing here? How can one get the pre-configured caches of a cache container?

All samples that are out there don't address this issue and I'm not sure whether these people are aware of the fact that they get an unconfigured cache instead. Samples always only show the resource lookup of the container an getting the default cache instance. There is no check of configuration ...

So is there anyone out there (maybe a contributor of infinispan) who knows the answer? Thanks and many appreciation in advance ;)

Upvotes: 1

Views: 810

Answers (1)

Paul Ferraro
Paul Ferraro

Reputation: 326

Injected your caches directly.

@Resource(lookup = "java:jboss/infinispan/cache/TEST/x")
private Cache<?, ?> cacheX;
@Resource(lookup = "java:jboss/infinispan/cache/TEST/y")
private Cache<?, ?> cacheY;

Upvotes: 5

Related Questions