spring boot - WildFly 10, JCache - method caching -


i have simple application using spring boot. wanted allow method caching jsr107 - jcache. of tutorial put code :

@cacheresult(cachename = "testpoc") public country getcountry(integer id){     system.out.println("---> loading country code '" + id + "'");     return new country(id, "x", "title"); } 

with pom file

... <dependencies>     <dependency>         <groupid>org.springframework.boot</groupid>         <artifactid>spring-boot-starter-web</artifactid>         <version>1.4.0.release</version>     </dependency>     <dependency>          <groupid>org.springframework.boot</groupid>          <artifactid>spring-boot-starter-cache</artifactid>          <version>1.4.0.release</version>     </dependency>      <dependency>         <groupid>javax.cache</groupid>         <artifactid>cache-api</artifactid>         <version>1.0.0</version>     </dependency> </dependencies> ... 

(dependency 'spring-boot-starter-web' there simple rest service call getcountry method)

everything works documentations says - method invoked once.

now wanted try on wildfly 10 application server

i have modified pom file :

  • excluded tomcat
  • exluded spring-boot-starter-cache
  • added infinispan-jcache (because want use cache configured / managed wildfly in standalone/domain.xml)

check pom file here on pastebin.

problem is, receiving following error : cannot find cache named 'java:jboss/infinispan/app-cache'

(i have tried use both jndi assigned , name infinispan cache configured in wildfly).

following code created cache object (so can used it) :

cachemanager cachemanager = caching.getcachingprovider().getcachemanager(); cache<string, string> cache = cachemanager.createcache("testpoc", new mutableconfiguration<string, string>()); 

question :

  • it possible use jcache method caching on wildfly 10 using infinispan managed wildfly ?
  • or infinispan should used method caching jcache, hence jcache has "more functionality" infinispan.

thank much

ps :it not problem me put whole code on github , post link - few lines of code ...

there couple of problems approach let me go through them in steps.

at first need use proper infinispan setup. infinispan bits shipped wf should considered internal or private. in order use infinispan in app - either add org.infinispan:infinispan-embedded deployment or install infinispan wildfly modules. can find installation guide here (it's bit outdated still, procedure same - unpack modules wf , use dependencies manifest.mf entry).

once have installed infinispan (or added app), need consider whether want use spring cache or jcache. if you're interested in using annotations - recommend former since it's easier setup (all need add @enablecaching 1 of configurations). spring cache create infinispan cachemanager bean. example can found here.

final note - if still need use jcache - use this manual setup caching provider.


Comments

Popular posts from this blog

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

mapreduce - Resource manager does not transit to active state from standby -

serialization - Convert Any type in scala to Array[Byte] and back -