In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces the relevant knowledge of "what are the Websocket technologies commonly used in Java development". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
1. Preface
Websocket is a protocol that HTML5 began to provide for full-duplex communication over a single TCP connection. WebSocket makes it easier to exchange data between the client and the server, allowing the server to actively push data to the client, and also supporting the client to send data to the server. Usually used for social chat, on-screen comments, multi-player games, collaborative editing, stock fund real-time quotes, automatic information update and other scenarios, technology selection is combined with their own business to choose the most suitable technical solution, there is no praise or criticism.
two。 Commonly used Websocket technology
2.1 Java Websocket specification
This is the specification provided by JavaEE, which includes client-side API and server-side API under the package javax.websocket. Server-side API completely depends on client-side API, but adds some functions based on it, so you only need to import server-side dependencies. The specific implementation needs to be provided by a Web container, JavaEE server or framework. Our commonly used Web containers such as Tomcat, Undertow, and so on all support it.
Pros: easy to integrate and native Java support.
Disadvantages: high coupling with shared containers such as Web servers, and broadcast and multicast need to be controlled by themselves. The concurrency is low, tuning is troublesome, and there are compatibility problems.
2.2 SockJS
SockJS is a browser JavaScript library that abstracts Websocket. SockJS provides you with a consistent, cross-browser Javascript API that creates a low-latency, full-duplex, cross-domain communication channel between browsers and Web servers. SockJS attempts to use native WebSockets first. If it fails, it will try various other browser-specific transport protocols, such as xhr-streaming, Server sent events, and long polling. It is also often combined with STOMP, a message-oriented simple text protocol, to simplify its use. In fact, this protocol is used in the Websocket component of Spring.
Advantages: active community, mature technology, rich protocol stack, a full set of Spring solutions, strong compatibility, and can be combined with publish and subscribe model.
Disadvantages: need to learn SockJS and STOMP, disconnected reconnection, heartbeat detection, binary support is not good.
2.3 Socket.IO
Socket.IO is a real-time application framework based on Node.js, which is widely used in instant messaging, notification and message push, real-time analysis and other scenarios, but it provides Netty-based server implementation and client implementation, and supports Websocket and long polling at the same time. In addition to the common scenarios of Websocket, we can use this component to implement Android and IOS message push.
Advantages: good performance, support for broadcast, multicast, disconnection reconnection, heartbeat detection, binary. Support Android and IOS platforms. The community is active.
Disadvantages: need to self-encapsulate the integration with Spring, the server is not community maintenance, resource consumption is large.
2.4 ReactiveStream
Some response flow specifications and frameworks also implement Websocket. Spring Webflux and RSocket are among the representatives, and the authorities have released some related DEMO so far.
Advantages: high throughput, high performance.
Disadvantages: the technology is relatively new and there are few learning materials.
This is the end of the content of "what are the Websocket technologies commonly used in Java development". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.