SSE & Websocket Service¶
1. Introduction¶
1.1 Server Sent Event (SSE)¶
The SSE (Server Sent Event) service uses one way communication to view the events/ messages coming as the output of MR or CEP rule. It allows client (browser or any client) to view the events/ messages generated in the TCUP server on any topic of kafka topic by specifying the topic name or on any topic under a specific consumer group message queue by specifying the topic name along with consumer group(message queue) name. The main advantage of using SSE is that once a topic is subscribed, the user automatically gets the data whenever data comes to the topic . If the server does not have the data available, the server holds the request open until new data is made available.
1.2 Websocket¶
Websocket is used to inject high volume data or events/ messages to the TCUP. This support two way communication:
Client can inject high volume data to the server using websocket protocol. To inject the data to server user specifies the kafka Topic Name. This publisher can be used instead of MR SendRequest() for better performance.
Server can also push events/ messages to the client like server sent event. Similar to SSE, Websocket also allows to view the events/ messages which are posted either on any random topic by specifying the topic name or on a topic specific to a consumer group( message queue) by specifying the queue name.
1.3 Intended Audience¶
The intended audience of this document is anyone who wants to have an overview of TCUP SSE and Websocket Service. After going through this document, the user will understand the capability of TCUP SSE and Websocket Service.
2. Key Concepts¶
In order to use the Service, a user needs to understand some of the basic concepts and building blocks. Please refer the following section for the concepts:
2.1 Server Sent Event (SSE)¶
This is a one way communication where the server pushes events/messages to the client. It allows the client to view the events/messages generated in the TCUP server.
2.2 Websocket¶
This is used to inject or subscribe high volume data or events/messages to TCUP. This supports two way communication. Clients can push high volume data to the server. Server can also push events/messages to the client like server sent event.
2.3 Topic¶
Topic is an incoming message repository that functions like a funnel where all the messages that enter gets stored and published to different destinations .
Consumer – A consumer subscribes to a topic to get the messages.
Consumer group – A consumer group is a group of related consumers that perform a task.It is useful for multi thread subscription for kafka topic.
3. Features¶
3.1 SSE Features¶
The following are the main features of SSE:
Mainly used for the situations where applications require a longer-term connection to the web server.
Continuously gets updates from the server.
Once the connection is established, user does not have to refresh/ reconnect or request the server over and over again.
If the server does not have data available, the server holds the request open until new data is made available.
SSE uses traditional HTTP and can work behind all firewalls.
3.2 Websocket Features¶
The following are the main features of Websocket:
Provides a full-duplex communication channel that operates through a single socket over the web.
Reduces unnecessary network traffic and latency as it supports upstream and downstream communications over a single connection.
Websocket protocol is initiated by HTTP protocol and it switches to TCP (Websocket) protocol during the initial handshake between the client and the server.
As initiated through HTTP, it can work behind all firewalls.
A WebSocket detects the presence of a proxy server and automatically sets up a tunnel to pass through the proxy.
High data rate achieved as data is transferred through TCP protocol.
4. Reference Document¶
For more details about this service please refer to the following documents:
SSE User guide
Websocket User guide
API Guide