使用 spring rmi 在 rmi 服务器之间共享对象
我正在使用 RMI Spring 功能,并且是该框架的新手。
在我的应用程序中,有一个客户端使用 RMI Spring 访问在服务器上运行的服务。现在,如果最多没有。该服务的用户连接时,会引发连接拒绝异常,我正在捕获它,然后将控制权转移到运行备份服务并执行相同任务的另一台服务器。 任务很简单。我们将用户名添加到数组列表中。
问题:要添加用户的 Arraylist 对于每个服务器来说都是本地的,当发生异常后控制权转移到新服务器时,用户会添加到在新服务器上创建的 arraylist。
如何在服务器/应用程序之间共享同一个 arraylist 对象,以便当异常发生或不发生时,程序继续在同一个 arraylist 中添加用户名?
请建议。
谢谢。
Am using RMI Spring capablilites and new to this framework.
In my application there is a client which access a service running on server using RMI Spring. Now, if maximum no. of users to that service connect, connection refuse exception is thrown and I am catching it and then transferring the control to another server which runs a backup service and performs the same task.
The task is simple. We are adding user names to an arraylist.
Problem: Arraylist to which users are getting added is local to each of the server and when control transfers to new server after exception has occured, the users get added to the arraylist which was created at the new server.
How can the same arraylist object be shared across the servers/application, so when the exception occurs or doesn't occur, program continues to add usernames in the same arraylist?
Please suggest.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在服务器之间共享阵列不是您需要解决的问题。问题是您选择的负载平衡方法并不正确。
最好有一个组件负责向客户端提供有关负载最少的服务器的信息。决定哪个服务器更适合连接不是客户端的责任。客户端唯一需要的是一个可用的服务器。
Sharing the array among servers is not a problem you need to solve. The problem is you've chosen load balance approach which is not really correct.
It would be much better to have a component which is responsible for providing information to a client about least loaded server. It's not a client responsibility to decide which server is better to connect. The only thing client needs is a working server.