Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between JMX and RMI

What is the purpose of JMX and what is it used for? I have been scanning through some of the tutorials on JMX and all they do is register some Mbeans and invoke those Mbeans from jconsole. If that is its purpose, then what is the difference between JMX and RMI (remote procedure call)?

Thanks in advance!

like image 525
hnm Avatar asked Feb 24 '11 05:02

hnm


People also ask

Does JMX use RMI?

By default, Java provides a remote JMX connector that is based on Java RMI (Remote Method Invocation).

What is JMX port used for?

The JMX technology can be used for out-of-the-box management of the Java VM. The Java Virtual Machine (Java VM) is highly instrumented using the JMX technology. You can start a JMX agent to access the built-in Java VM instrumentation, and thereby monitor and manage a Java VM remotely.

What is JMX?

The Java Management Extensions (JMX) API is a standard —developed through the Java Community Process (JCP) as JSR 3—for managing and monitoring applications and services.

What is JMX monitoring?

Java Management Extensions (JMX) is a specification for monitoring and managing Java applications. It enables a generic management system to monitor your application; raise notifications when the application needs attention; and change the state of your application to remedy problems.


2 Answers

JMX architecture.

Yes in JMX we register our objects in mbean server using the ObjectName and objectReference. We can then change attributes or invoke methods remotely.

A connector makes a Java Management Extensions (JMX) technology MBean server accessible to remote Java technology-based clients.Many different implementations of connectors are possible. In particular, there are many possibilities for the protocol used to communicate over a connection between client and server.Some Connectors defined by the JMX Remote API specification are

  • "RMI Connector": This standard Remote Method Invocation (RMI) protocol must be supported by every implementation that conforms to the JMX Remote API standard.
  • "Generic Connector": The JMX Remote API standard also defines an optional protocol based directly on TCP sockets, called the JMX Messaging Protocol (JMXMP). An implementation of the standard can omit the JMXMP connector, but must not omit the RMI connector. The Java SE platform does not include the optional JMXMP connector.
  • "User-Defined Protocols": A connector can also implement a protocol that is not defined in the JMX technology.

If you look at the above architecture a connector provides full remote access to the MBeanServer API using various communication frameworks (RMI, IIOP, JMS, WS-* …), while an adaptor adapts the API to another protocol (SNMP, …) or to Web-based GUI (HTML/HTTP, WML/HTTP, …).

Generally we use JMX connectors to connect to the MBean server but we can chose other connectors as well.

To sum up JMX is an java technology and RMI is for Remote Method Invocation a Java specific implementation of a Remote Procedure Call interface which can be used in the JMX to communicated remotely.

like image 84
Aniket Thakur Avatar answered Oct 12 '22 00:10

Aniket Thakur


'Remote Procedure Call' is a distributed computing concept where a process running on one host can call a procedure on another remote host. RMI in Java is one implementation of this concept.

MBeans are bean classes that can be registered with a JMX bus to listen to events arriving on the bus or to send events on the bus or to collect various sorts of data from the other participating Mbeans etc. It is most often used for health monitoring of application servers etc. It can check the number of active connections, amount of free memory and many other statistics to an analysis engine. And yes, they can be invoked remotely using an RPC mechanism. This is vital to its functioning as data collectors since in a cluster of application servers the data has to be fetched from all the collectors and collated at one place for analysis.

like image 32
rahulmohan Avatar answered Oct 11 '22 22:10

rahulmohan