Search

5.4.2. Registering the CacheJmxWrapper with the MBeanServer

download PDF
The best way to ensure the CacheJmxWrapper is registered in JMX depends on how you are deploying your cache.

5.4.2.1. Programatic Registration with a Cache instance

Simplest way to do this is to create your Cache and pass it to the JmxRegistrationManager constructor.
   CacheFactory factory = new DefaultCacheFactory();
   // Build but do not start the cache
   // (although it would work OK if we started it)
   Cache cache = factory.createCache("cache-configuration.xml");

   MBeanServer server = getMBeanServer(); // however you do it
   ObjectName on = new ObjectName("jboss.cache:service=Cache");
   
   JmxRegistrationManager jmxManager = new JmxRegistrationManager(server, cache, on);
   jmxManager.registerAllMBeans();

   ... use the cache

   ... on application shutdown

   jmxManager.unregisterAllMBeans();
   cache.stop();

Red Hat logoGithubRedditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

© 2024 Red Hat, Inc.