The last few days I take a look to use infinispan to manage a cache with my applications. I have some ears applications that runs on same wildfly and my purpose is to have a local cache that all my application can use. This cache will not be shared between the nodes. My intention was to use infinspan with jcache, so in this manner I can annotate my functions to cache the result. I'm not interested in a replicated cache, because the data that I'm going to cache will be evicted every 5 minutes and the data will not be duplicated on the nodes (the session of the client is persisted and the clients call these function with differente key value a lot of times).
I'm using wildlfy 14 with the standalone-full profile and I took some look into the documentation online. I added a new cache container to the configuration system, also via the cli
/subsystem=infinispan/cache-container=container-name:add
/subsystem=infinispan/cache-container=container-name/local-cache=container-name-default:add
/subsystem=infinispan/cache-container=container-name/local-cache=container-name-sd:add
I see that the container and the cache are not published with jndi and using the wildfly console I can't find the added caches in the jndi runtime string. Without the jndi string, I can't access to the cache.
Becasue at first moment my intenction was to use JCache, I found the documentation on infinispan website to add the complete module of infinispan to wildlfy. To use the module donwloaded, I extended wildfly with the infinispan module in extensions tag section. Using the standalone full profile, I had some errors with the access to the cache and the @CacheResult annotation wasn't fired, also with the beans.xml defined with the interceptors
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd" version="1.1" bean-discovery-mode="all">
<interceptors>
<class>org.infinispan.jcache.annotation.InjectedCacheResultInterceptor</class>
<class>org.infinispan.jcache.annotation.InjectedCachePutInterceptor</class>
<class>org.infinispan.jcache.annotation.InjectedCacheRemoveEntryInterceptor</class>
<class>org.infinispan.jcache.annotation.InjectedCacheRemoveAllInterceptor</class>
</interceptors>
At the end I found that using standalone ha wildfy profile and adding a jgroup to the cache container, I'm able to publish the cache with a jndi string and use it.
Is there a simple method to create and access a local cache with infinispan and wildfly 14? Do someone can provide an example with an ear application? Is it correct that I need to use the ha profile to define new cache container with jgroups? I found that in the full wildfly profile, the infinispan cache is usde only for internal use, so it is necessary to use the ha profile as I said before.
Thanks for every answer and I hope I was enough clear.