SSE

Introduction

The SSE (Server Sent Event) Service is used to view the events/messages which comes as the output of MR or CEP rule. It allows the client (browser or any client) to view the events/messages generated in TCUP on any topic of topic exchange by specifying the topic exchange name and topic name or on any message queue by specifying the queue name.

Purpose of the Document

After going through this document, the users will be able to subscribe to any Topic Exchange/ Message queue and view data posted to the Topic Exchange/ Message queue.

Reference Document

Please refer to the the following documents to get more details on SSE Viewer

  • To understand the basic concepts of SSE Viewer please refer to the Concept guide.

  • For API details please refer to the API guide.

Browser Support

TCUP SSE Viewer page is compatible with most of the browsers except Internet Explorer.

Subscribe/View Data from TCUP Portal

The SSE viewer portal page is embedded under services tab on the left hand side of the portal home page as shown in the image below:

../_images/sse2.PNG

On Clicking the SSE Viewer on the left hand side, the SSE viewer page is launched. The users have to provide the Input Type and kafka Topic Exchange Name if input type is selected as Topic Exchange. If input type is selected as Message Queue then user have to provide Queue Name which is nothing but the consumer group name and Topic Exchange Name which is the kafka topic where data to be published .

../_images/sse3.PNG ../_images/sse3_1.PNG

Note

Topic Exchange Name should be same as provided in MR rule (whose output user want to see) and the rule should be in running status.

After providing the above details click on Start button to establish the connection to the server. The connection status and the connection URL will appear as soon as the connection starts as shown in the image below:

../_images/sse4.PNG

Connection URL

The SSE connection URLs can be used from any outside SSE client to subscribe data from the mentioned topic/queue.

The following are the different connection URLs:

SSE URLs for apiKey User

  • SSE URL to view from queue:

https://<BaseURL>/liveMessages/v1.0/MessageQueue/start?apiKey=<your apikey>&QueueName=<queue>&Exchange=<topicExchange>

  • SSE URL to view from Topic:

https://<BaseURL>/liveMessages/v1.0/TopicExchange/start?apiKey=<your apikey>&Exchange=<topicExchange>&Topic=<topic>

SSE URLs for JWT User

  • SSE URL to view from queue:

https://<BaseURL>/liveMessages/v1.0/MessageQueue/start?token=<your JWT>&QueueName=<queuename>&QueueName=<queue>&Exchange=<topicExchange>

  • SSE URL to view from topic:

https://<BaseURL>/liveMessages/v1.0/TopicExchange/start?token=<your JWT>&Exchange=<topicExchange>&Topic=<topic>

Input JSON and Sample Output

To view the output, data should be posted as the input of MR rule and the output should be checked at SSE viewer. For testing purpose, create a simple buffer rule. Refer MR user guide. for creating the same.

The following is the sample input JSON to post data. Refer Pulish Observation Data to post data.

  • Input SOS JSON

{
  "version": "1.0.1",
  "observations": [
    {
         "sensor": "NEXUS1",
         "feature": "room1",
         "record": [
             {
                 "starttime": "1-JAN-2018 15:30:03 IST",
                 "output": [
                     {
                         "name": "OutsideSensorTemp",
                         "value": "46.0",
                         "type": "decimal"
                     },
                     {
                         "name": "temp",
                         "value": "99",
                         "type": "quantity"
                     }
                 ]
             }
         ],
         "meta-data": []
      }
    ]
 }

Note

Sensor name of the input JSON data should be the same as sensor ID provided in MR rule else the data will be discarded.

  • Corresponding Output

../_images/sse5.PNG
  • The total number of messages received by the consumer is shown under Messages Received.

  • A Clear Message button is also provided to clear the received data.

  • Users just need to click on the Stop button to stop subcribing the data .

Subscribing using Java-client

A java client SSEclient.jar is provided along with .properties file to serve the same purpose of SSE viewer.

The steps mentioned below have to be followed in order to use the java subscriber:

  • In the .properties file provide the properties BASEURL, APIKEY, TopicExchage and Queue Name.

  • Run the .jar file along with the path for the .properties file as arguments as shown in the image below.

../_images/sse6.PNG