java JMX 和 RMI 的区别

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5100793/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 09:26:33  来源:igfitidea点击:

Difference between JMX and RMI

jakarta-eejmxjava

提问by hnm

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)?

JMX 的目的是什么,它的用途是什么?我一直在浏览一些关于 JMX 的教程,他们所做的就是注册一些 Mbeans 并从 jconsole 调用这些 Mbeans。如果这是它的目的,那么 JMX 和 RMI(远程过程调用)之间有什么区别?

Thanks in advance!

提前致谢!

采纳答案by rahulmohan

'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.

“远程过程调用”是一种分布式计算概念,其中一个主机上运行的进程可以调用另一台远程主机上的过程。Java 中的 RMI 是这一概念的一种实现。

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.

MBeans 是 bean 类,可以注册到 JMX 总线以侦听到达总线的事件或在总线上发送事件或从其他参与的 Mbeans 等收集各种类型的数据。它最常用于健康监控应用程序服务器等。它可以检查活动连接数、可用内存量和许多其他统计数据到分析引擎。是的,它们可以使用 RPC 机制远程调用。这对其作为数据收集器的功能至关重要,因为在应用服务器集群中,必须从所有收集器中获取数据并在一个地方进行整理以进行分析。

回答by Aniket Thakur

JMX architecture.

JMX 架构。

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

是的,在 JMX 中,我们使用ObjectName和在 mbean 服务器中注册我们的对象objectReference。然后我们可以远程更改属性或调用方法。

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

连接器使基于 Java 技术的远程客户端可以访问 Java 管理扩展 (JMX) 技术 MBean 服务器。连接器的许多不同实现都是可能的。特别是,用于通过客户端和服务器之间的连接进行通信的协议有很多可能性。 JMX 远程 API 规范定义的一些连接器是

  • "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.
  • RMI 连接器”:每个符合 JMX 远程 API 标准的实现都必须支持这个标准的远程方法调用 (RMI) 协议。
  • 通用连接器”:JMX Remote API 标准还定义了一个直接基于 TCP 套接字的可选协议,称为 JMX 消息传递协议 (JMXMP)。标准的实现可以省略 JMXMP 连接器,但不能省略 RMI 连接器。Java SE 平台不包括可选的 JMXMP 连接器。
  • 用户定义的协议”:连接器也可以实现 JMX 技术中未定义的协议。

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, …).

如果您查看上述架构,连接器使用各种通信框架 ( RMI, IIOP, JMS, WS-* …)提供对 MBeanServer API 的完全远程访问,而适配器则使 API 适应另一个协议(SNMP, …)或基于 Web 的 GUI(HTML/HTTP, WML/HTTP, …).

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

通常我们使用 JMX 连接器连接到 MBean 服务器,但我们也可以选择其他连接器。

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.

综上所述,JMX 是一种 Java 技术,而 RMI 是用于远程方法调用的远程过程调用接口的 Java 特定实现,它可以在 JMX 中用于远程通信。

回答by rahulmohan

JMX is a generic API for publishing an interface to monitor the internals of a Java application ( A Java version of SNMP ).

JMX 是一个通用 API,用于发布接口以监视 Java 应用程序(SNMP 的 Java 版本)的内部结构。

RMI is for Remote Method Invocation a Java specific implementation of a Remote Procedure Call interface, they are not related at all.

RMI 是用于远程方法调用的远程过程调用接口的 Java 特定实现,它们根本不相关。