In REST-like mode, use JSON requests to subscribe, publish, and unsubscribe to data in ESP projects.
For more information on subscriber and publisher options, see the Java SDK API reference located at STREAMING_HOME/doc/sdk/java/index.html.
The topic value in these requests can also use RESTful URLs. For example, http://localhost:9091/espws/restservice/workspaces/<workspace>/projects/<project>/streams/<window-or-stream>.
{ "topic": "/<workspace>/<project>/<window-or-stream>", "messageType": "SUBSCRIBE", "subscribeOptions": { "gd": "<string>", "base": "<boolean>", "baseDrainTimeout": "<integer>", "droppable": "<boolean>", "lossy": "<boolean>", "pulseInterval": "<integer>", "queueSize": "<integer>", "shineThrough": "<boolean>", "preserveBlocks": "<boolean>" }, "authorization": "Basic <auth-data>" }
If no window or stream is specified for topic, subscription requests use SQL statements:
{ "topic":"/<workspace>/<project>", "messageType":"SUBSCRIBE", "subscribeOptions": { }, "sql":"<SQL-SELECT-statement>", "authorization":"Basic <auth-data>" }
{ "topic": "/<workspace>/<project>/<window-or-stream>", "event": { "count": "<integer>", "time": "<msdate>", "opCode": "<INSERT/UPDATE/DELETE/UPSERT/SAFEDELETE>", "value": [ { "<column>": "<value>" }, { "<column>": "<value>" } ] }, "publishOptions": { "async": "<boolean>", "bufferSize": "<integer>", }, "authorization": "Basic <auth-data>", "messageType": "PUBLISH" }
The async publisher option is processed only for the first publish request; it is ignored in all subsequent publish calls.
The async option controls how the WebSocket Provider sends messages to the ESP project. If set to false, the WebSocket Provider waits for ESP to send an acknowledgment to each publish request. Regardless of the setting, all messages from the websocket client to the WebSocket Provider are asynchronous.
The bufferSize option controls how frequently the WebSocket Provider commits the published messages to the ESP project. This option is processed on every call, so you can change the commit frequency.
{ "topic": "/<workspace>/<project>/<window-or-stream>", "messageType": "UNSUBSCRIBE", "authorization": "Basic <auth-data>" }