简体   繁体   English

如何编写Java RMI回调或RMI侦听器或双向RMI

[英]How to write java RMI callbacks or RMI Listener or bidirectional RMI

I am writing an RMI application. 我正在编写一个RMI应用程序。

I am able to perform RMI. 我能够执行RMI。 Data are transferring between client and server via RMI. 数据通过RMI在客户端和服务器之间传输。

Client should be always up to receive/updates the server side data. 客户端应始终处于接收/更新服务器端数据的状态。

Is it possible to have a listener which can transport or notify the data updates/modification from server to clients. 是否可能有一个侦听器,可以从服务器向客户端传输或通知数据更新/修改。 I mean whenever data's are updated/modified at server side,client should be automatically updated. 我的意思是,每当在服务器端更新/修改数据时,客户端都应自动更新。 Please let me know, if there exist any RMI Call be listener which can be used for this task. 请让我知道,如果存在可用于此任务的RMI Call be listener。

Also, what are all the security standards to be followed while performing RMI? 另外,执行RMI时要遵循的所有安全标准是什么?

How can we update server side object via client? 我们如何通过客户端更新服务器端对象? If i need to update the server side instance, can i update it using client? 如果我需要更新服务器端实例,可以使用客户端来更新它吗?

Please guide me to achieve this. 请指导我实现这一目标。

An RMI callback is no different from an RMI server object, except that it is exported from the client instead of the server. RMI回调与RMI服务器对象没有什么不同,只不过它是从客户端而不是从服务器导出的。

However it's usually an infeasible architecture due to client-side firewalls. 但是,由于客户端防火墙的原因,它通常是不可行的架构。 And using a remote callback as a listener has major overheads that make it typically infeasible even within a LAN. 而且,将远程回调用作侦听器会产生大量开销,即使在局域网内,也通常使其不可行。 You really don't want to do this. 您真的不想这样做。

The last part of your question is really about how to write a remote method call, for which you should consult the Oracle RMI Tutorial. 问题的最后一部分实际上是关于如何编写远程方法调用的,对此,您应该查阅Oracle RMI教程。

I work on a similar server side application. 我在类似的服务器端应用程序上工作。 The way we handle it is, Client to Server communication is synchronous and via RMI (over HTTP). 我们处理的方式是,客户端到服务器的通信是同步的,并通过RMI(通过HTTP)进行。 However, responses to the client from the server are sent via JMS messaging queue. 但是,从服务器对客户端的响应是通过JMS消息传递队列发送的。 Each client has a dedicated queue to which the client subscribes to. 每个客户端都有一个专用的队列,客户端可以订阅。 On client login the queue gets created and on logout the queue is destroyed. 在客户端登录时,将创建队列,而在注销时,将销毁队列。 This way the client responses from the server are async in nature. 这样,来自服务器的客户端响应本质上是异步的。 The client responsiveness increases as well. 客户的响应度也会提高。 Had the server responses being synchronous in nature, the client could have appeared frozen. 如果服务器响应本质上是同步的,则客户端可能已冻结。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM