79126986

Date: 2024-10-25 18:51:21
Score: 1.5
Natty:
Report link

I've been going through a bunch of documentation and SO posts and I found this solution to work (Is it possible to enable remote jmx monitoring programmatically?)

I'm sure you can translate your XML config into a @Configuration class to modernize your app as well:

    @Bean
    Registry rmiRegistry() throws Exception {
        
        var jmxPort = getJmxPort(); //get your port from a property? jmx.port
        var registry = LocateRegistry.createRegistry(jmxPort);
        MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
        JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://0.0.0.0:"+jmxPort+"/jndi/rmi://127.0.0.1:"+jmxPort+"/jmxrmi");
        JMXConnectorServer srvr = JMXConnectorServerFactory.newJMXConnectorServer(url, getJmxEnvironment(), mbs);
        srvr.start();
        return registry;
    }

Now for the getJmxEnvironment() method, add the custom objects to this map (the environment with jmx.remote.rmi.client.socket.factory and jmx.remote.rmi.server.socket.factory to your implementations)

Finally it wouldn't hurt to check these docs for some extra configuration points: https://docs.oracle.com/en/java/javase/17/docs/api/java.management.rmi/javax/management/remote/rmi/package-summary.html

Reasons:
  • Blacklisted phrase (1): Is it possible to
  • Long answer (-1):
  • Has code block (-0.5):
  • User mentioned (1): @Configuration
  • Low reputation (1):
Posted by: manrodriguezf