Skip to content

Instantly share code, notes, and snippets.

@bparry02
Created November 23, 2014 18:29
Show Gist options
  • Select an option

  • Save bparry02/f39f2901f49a9f9ce4bc to your computer and use it in GitHub Desktop.

Select an option

Save bparry02/f39f2901f49a9f9ce4bc to your computer and use it in GitHub Desktop.
Infinispan close cache example
@Named
@ApplicationScoped
public class GreetingCacheManager {
@Inject
@GreetingCache
private Cache<CacheKey, String> cache;
@PreDestroy
public void closeCache() {
cache.getCacheManager().stop();
}
...
}
@bparry02
Copy link
Author

This eliminates the following error:

13:13:44,561 ERROR [org.infinispan.jmx.JmxUtil] (MSC service thread 1-16) ISPN000034: There's already an cache manager instance registered under 'org.infinispan' JMX domain. If you want to allow multiple instances configured with same JMX domain enable 'allowDuplicateDomains' attribute in 'globalJmxStatistics' config element

Keep in mind, the class that should contain this @PreDestroy method should have @Singleton @Startup or be application-scoped as above.

Alternatively, if there is a @Producer method for the Cache or CacheManager, then you can use an @Disposes method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment