JAVA从服务器推送到客户端 [英] JAVA push from server to clients

查看:238
本文介绍了JAVA从服务器推送到客户端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



示例:服务器S,客户端A和B

我希望客户端通过服务器在没有延迟的情况下/ p>

客户端A要请求客户端B.
客户端A将向服务器S发出请求,没有问题。



所有的node.js / APE(PHP)技术人员是为网络设计的,但我不使用网络服务器。 Java有一个接近推送技术/框架的东西,不是web?



我真的更喜欢一个解决方案,不要求每个客户端使用自己的保留端口(我不希望最终为每个客户端1 WebService例如)



注意:所有客户端在同一台机器上。

解决方案

几个选项...




  • 普通插座通信。 java.net.Socket,java.net.ServerSocket。最大的灵活性,但需要低层TCP / IP API /概念的知识。


  • 基于TCP / IP上的基于Java的RPC层。当客户端和服务器都在Java并且通常在同一子网中时工作良好。


  • Spring Remoting,它实际上是相当不错的。


  • 双向网络服务。


  • JMS就像已经提到的人一样。


  • 分布式数据结构,请查看 http://www.hazelcast.com/




有很多可供选择的选项,不需要网络服务器。


I would like to have the clients query each other through the server without delay ( = no polling interval ).

Example: Server S, clients A and B

Client A wants to request Client B. Client A will make a request to the server S, no problem there. Then Server S needs to be able to request Client B but how to do that without polling?

All the node.js/APE (for PHP) technos are designed for the web, however I don't use a web server for that. Does Java has something close to a push technology/framework that is not web?

I would really prefer a solution that doesn't require each client to use their own reserved port (I don't want to end up with 1 WebService per client for example)

Note: all the clients are on the same machine.

解决方案

A couple of options...

  • Plain socket communication. java.net.Socket, java.net.ServerSocket. Maximum flexibility but requires knowledge of low level TCP/IP API/concepts.

  • The good old RMI. Java based RPC layer on top of TCP/IP. Works good when client and server are both in Java and generally in same subnet. May give problems when client and/or server are natted.

  • Spring Remoting, it's actually pretty decent.

  • Bi-Directional Web Services. i.e. clients host their own WSes which the Server calls when it needs to do a callback.

  • JMS as someone already mentioned.

  • Distributed Data Structures, Check out http://www.hazelcast.com/

Lots of options to chose from, no need for webserver.

这篇关于JAVA从服务器推送到客户端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆