Java HTTP推送(消息传递)的最佳解决方案 [英] Best solution for Java HTTP push (messaging)

查看:776
本文介绍了Java HTTP推送(消息传递)的最佳解决方案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们希望将数据从服务器推送到客户端,但只能使用HTTP(端口80)。消息传递的最佳解决方案是什么?一个想法是 Comet 。是否有其他想法或框架可以提供JMS over HTTP。 (是的,ActiveMQ的支持它,但waggly IMHO。和JXTA支持它太多,但结构复杂。东西简单是优选的。)

We want to push data from a server to clients but can only use HTTP (port 80). What is the best solution for messaging? One idea is Comet. Are there other ideas or frameworks which offer lets say JMS over HTTP. (Yes, ActiveMQ supports it too, but waggly IMHO. And JXTA supports it too but the configuration is complicated. Something simple is preferred.)

推荐答案

最简单的解决方案有许多原因,就是使用基于Comet的方法(就像你提到的那样)。这意味着客户端(您希望推送消息)打开长期存在的HTTP连接。这些连接保持打开状态,直到超时或您向客户端发送消息。一旦发生任何一种情况,客户端就会打开一个新的连接。

The simplest solution for many, many reasons is to use a Comet based approach (like you mention). This means the clients (to whom you want to "push" messages) open long-lived HTTP connections. Those connections stay open until they time out or you send the client a message. As soon as either happens the client opens a new connection.

直接连接到客户端可能有问题,原因有很多:它们可能在防火墙之后,不允许这样做,它们可能是代理等等。

Directly connecting to clients could be problematic for many reasons: they could be behind firewalls that disallow that, they could be behind proxies and so on.

除非你的客户是真正的服务器(在这种情况下你真的是客户端),让他们联系你并发送回应模仿推送。

Unless your clients are real servers (in which case you're really the client), have them contact you and send a response to mimic push.

这篇关于Java HTTP推送(消息传递)的最佳解决方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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