Server side push with java

风流意气都作罢 提交于 2019-12-19 04:58:29

问题


is it any simpler way then cometd as long-polling framework for java? Because what I need - is client specifies some parameters and sends them to server. Server process them and starts contonuously pushing messages back to client (looks like Thread-per-Service?). Client receivs messages and displays them. Client has possibility to stop listening and actually stop server's service to send messages. Maybe I'm too lazy, but cometd's examle was not that short and transparent as I wanted it to be.

Not HTML5 based.


回答1:


With SSE ( server sent events ) you can do exactly what you explained you want to do, but unfortunately it's HTML5 technology .
If your interested you can check html5rocks for further information.




回答2:


Well if you are too lazy for cometd or reverse AJAX you can deploy a web service endpoint to your client (preferably restful and not SOAP) and have your server send back messages to your web service (acting as a client).

It is simple to implement this.

In your clien't initial request to the server, along with the other parameter, you can also send the port (or URL) that your endpoint is listening for notification.

Then you just have to define the notification events and implement the rest of the logic.




回答3:


These guys Atmosphere Asynchronous WebSocket/Comet Framework really made nice job at simplifying the server push process with fallbacks mechanism when browser and/or server parts does not support websockets



来源:https://stackoverflow.com/questions/7698739/server-side-push-with-java

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!