Push REST API to subscribe to a given topic and receive messages published under that topic.
When the client connects to this URL, the response is suspended,
and a
Comet Long Polling session is initiated.
By default a server-side timeout of 1 minute is applied to the suspended response.
The client code is expected to handle the closing of the connection from the server side and
perform a reconnect if necessary. A maximum time out of 5 minutes can be specified.
Upon receiving a message on the subscribed topic, the message will be formatted in
XML or JSON format as requested and sent as response body to the suspended request.
Following the Long Polling protocol, the request will then be closed; it is left up
to the client to reopen a new request. JSON will be the default format if no extension is provided.
Cross Origin Request Support (CORS) is included so Java Scripts clients executed in
web browser can initiate subscribe REST calls from any domain.
Please refer to our code samples for client libraries that you can use to make Comet requests.
name | type | description | default | constraints | multivalued |
---|---|---|---|---|---|
fetch | query | Specifies the amount of information requested. Allowed values are: meta, metrics, all. "meta" returns only the topic and received on information; "metrics" returns "meta" plus all the metrics included in the message; "all" returns the whole message including its binary payload. | metrics | no | |
timeout | query | the timeout of the request in milliseconds. Defaults to 60000ms (= 60s = 1min). Max allowed value is: 300000 (= 300s = 5min) | 60000 | required | no |
topic | query | The topics list to subscribe to. The MQTT syntax for specifying topic wild card is accepted - e.g. edcguest/+/#. | yes |
media type | data type | description |
---|---|---|
application/json | EdcMessage (JSON) | Any message received from the subscriptions before timeout, or empty response. |
application/xml | edcMessage (XML) |
GET /streams/subscribe
Content-Type: */*
Accept: application/json
...
HTTP/1.1 200 OK
Content-Type: application/json
{
"topic" : "...",
"receivedOn" : 12345,
"payload" : {
"sentOn" : 12345,
"position" : {
"longitude" : 12345.0,
"latitude" : 12345.0,
"altitude" : 12345.0,
"precision" : 12345.0,
"heading" : 12345.0,
"speed" : 12345.0,
"timestamp" : 12345,
"satellites" : 12345,
"status" : 12345
},
"metrics" : {
"metric" : [ { }, { } ]
},
"body" : "..."
},
"uuid" : "...",
"edcTopic" : {
"systemTopic" : true,
"edcTopic" : true,
"alertTopic" : true,
"account" : "...",
"asset" : "...",
"semanticTopic" : "...",
"leafName" : "...",
"parentTopic" : "...",
"grandParentTopic" : "...",
"fullTopic" : "...",
"topicParts" : [ "...", "..." ]
}
}