Can JMX be used for normal communication between two remote Java processes to transfer some data back and forth? If so why JMX is preferred over RMI for the above scenario?
Documentation says JMX is for management/monitoring, c开发者_开发知识库an it be used for calling and return huge object collections?
Of course you can use JMX form plain communication and if you restrict yourself to Open MBeans you even don't require special type information on each side (i.e. custom jars used for deserialization).
Another advantage is of JMX communication is, that you can easily switch the protocol stack away from RMI. E.g. you can use a JMX HTTP-Bridge like Jolokia additionally or as replacement and gain some additional advantages (firewall friendliness, bulk requests, typeless communication)
The drawback of JMX used as a plain communication protocol is, that JMX blurs a layered architecture since MBeans can be registered in any layer (presentation, service, dao,...). Your probably only want to export your service layer remotely, with JSR-160 you have access to every MBean registered in any layer which might not be desirable from architectural point of view.
Because JMX is not as convenient as RMI. In RMI you can work with remote object via interface so it's like working with local object. But with JMX you have to invoke methods by string name with signature.
精彩评论