如何在java中实现一个简单的心跳传感器,当另一个应用程序关闭时做出响应
我的机器上有一个 GWT 版本的 java Pet Store,我想实现一个在另一台机器上的外部 Java 程序,并且只显示“打开”或“关闭” - 所以当我关闭 java 时Pet Store 在一台机器上,然后在另一台机器上从“开”切换到“关”。
我该怎么做呢?我玩过一点 RMI,但它相当麻烦。如有任何提示或建议,我们将不胜感激。
I got a GWT version of the java Pet Store working on my machine, and I'd like to implement an exteneral Java program that is on another machine, and just displays "On" or "off" - so when I turn off the java Pet Store on one machine, it will then switch from "On" to "Off" on the other machine.
How would I go about doing this? I've played with RMI a little, but it's quite cumbersome. Any tips or advice is appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我将创建一个程序来检查 Pet Store 计算机上正在运行的进程,以查看应用程序是否仍在运行并向远程计算机公开该功能。
-检查 Pet Store 是否仍在运行
-远程执行检查
这可能有点矫枉过正,但如果你如果需要,您可以使用 Web 服务设置远程检查。我个人喜欢 Axis2。
I'd create a program to check the running processes on the Pet Store machine to see if the application is still running and expose that capability to remote machines.
-Checking whether Pet Store is still running
-Executing the check remotely
It may be a bit overkill, but if you wanted, you could set up the remote check using web services. I personally like Axis2.
如果它是一个网络应用程序,只需使用 HttpClient 之类的东西来访问已知地址即可;如果你没有得到回应,那就是失败了。
If it's a web app, just use something like HttpClient to hit a known address; if you don't get a response, it's down.