API Docs - v1.0.11
Sink
websocket (Sink)
A Siddhi application can be configured to publish events via the Websocket transport by adding the @Sink(type = 'websocket') annotation at the top of an event stream definition.
Syntax
@sink(type="websocket", url="<STRING>", sub.protocol="<STRING>", headers="<STRING>", idle.timeout="<INT>", @map(...)))
QUERY PARAMETERS
Name | Description | Default Value | Possible Data Types | Optional | Dynamic |
---|---|---|---|---|---|
url | The URL of the remote endpoint. The url scheme should be either 'ws' or 'wss'. |
STRING | No | No | |
sub.protocol | The negotiable sub-protocol if server is asking for it. The sub.protocol should adhere to subprotocol1, subprotocol2,... format. |
null | STRING | Yes | No |
headers | Any specific headers which need to send to the server. The headers should adhere to 'key1:value1', 'key2:value2',... format. |
null | STRING | Yes | No |
idle.timeout | Idle timeout of the connection | -1 | INT | Yes | No |
Examples EXAMPLE 1
@Sink(type = 'websocket', url = 'ws://localhost:8025/abc',
@map(type='xml'))
define stream Foo (attribute1 string, attribute2 int);
A sink of type 'websocket' has been defined.
All events arriving at Foo stream via websocket will be sent to the url ws://localhost:8025/abc.
websocket-server (Sink)
A Siddhi application can be configured to publish events via the WebSocket transport by adding the @Sink(type = 'websocket-server') annotation at the top of an event stream definition.
Syntax
@sink(type="websocket-server", host="<STRING>", port="<STRING>", sub.protocol="<STRING>", idle.timeout="<INT>", tls.enabled="<BOOL>", keystore.path="<STRING>", keystore.password="<STRING>", @map(...)))
QUERY PARAMETERS
Name | Description | Default Value | Possible Data Types | Optional | Dynamic |
---|---|---|---|---|---|
host | host of the WebSocket server | STRING | No | No | |
port | port of the WebSocket server | STRING | No | No | |
sub.protocol | Sub-Protocols which are allowed by the service. The sub.protocol should adhere to subprotocol1, subprotocol2,... format. |
null | STRING | Yes | No |
idle.timeout | Idle timeout of the connection. If the idle.timeout = '-1' then the timer is disabled. | -1 | INT | Yes | No |
tls.enabled | This parameter specifies whether a secure connection is enabled or not. When this parameter is set to true , the keystore.path and the keystore.password parameters are initialized. |
false | BOOL | Yes | No |
keystore.path | The file path to the location of the keystore. If a custom keystore is not specified, then the system uses the default keystore file - wso2carbon.jks in the ${carbon.home}/resources/security directory. |
${carbon.home}/resources/security/wso2carbon.jks | STRING | Yes | No |
keystore.password | The password for the keystore. A custom password can be specified if required. If no custom password is specified, then the system uses wso2carbon as the default password. |
wso2carbon | STRING | Yes | No |
Examples EXAMPLE 1
@Sink(type = 'websocket-server', host='localhost', port='9025',
@map(type='xml'))
define stream Foo (attribute1 string, attribute2 int);
A sink of type 'websocket-server' has been defined.
All events arriving at Foo stream via websocket-server will be sent to the url ws://localhost:9025/abc.
Source
websocket (Source)
A Siddhi application can be configured to receive events via the WebSocket by adding the @Source(type = 'websocket') annotation at the top of an event stream definition.
When this is defined the associated stream will receive events from the WebSocket server on the url defined in the system.
Syntax
@source(type="websocket", url="<STRING>", sub.protocol="<STRING>", headers="<STRING>", idle.timeout="<INT>", @map(...)))
QUERY PARAMETERS
Name | Description | Default Value | Possible Data Types | Optional | Dynamic |
---|---|---|---|---|---|
url | The URL of the remote endpoint. The url scheme should be either 'ws' or 'wss'. |
STRING | No | No | |
sub.protocol | The negotiable sub-protocol if server is asking for it. The sub.protocol should adhere to subprotocol1, subprotocol2,... format. |
null | STRING | Yes | No |
headers | Any specific headers which need to send to the server. The headers should adhere to 'key1:value1', 'key2:value2',... format. |
null | STRING | Yes | No |
idle.timeout | Idle timeout of the connection | -1 | INT | Yes | No |
Examples EXAMPLE 1
@Source(type = 'websocket', url = 'ws://localhost:8025/websockets/abc',
@map(type='xml'))
define stream Foo (attribute1 string, attribute2 int);
Under this configuration, events are received via the WebSocket server and they are passed to Foo
stream for processing.
websocket-server (Source)
A Siddhi application can be configured to receive events via the WebSocket by adding the @Source(type = 'websocket-server') annotation at the top of an event stream definition.
Syntax
@source(type="websocket-server", host="<STRING>", port="<STRING>", sub.protocol="<STRING>", idle.timeout="<INT>", tls.enabled="<BOOL>", keystore.path="<STRING>", keystore.password="<STRING>", @map(...)))
QUERY PARAMETERS
Name | Description | Default Value | Possible Data Types | Optional | Dynamic |
---|---|---|---|---|---|
host | host of the WebSocket server | STRING | No | No | |
port | port of the WebSocket server | STRING | No | No | |
sub.protocol | Sub-Protocols which are allowed by the service. The sub.protocol should adhere to subprotocol1, subprotocol2,... format. |
null | STRING | Yes | No |
idle.timeout | Idle timeout of the connection. If the idle.timeout = '-1' then the timer is disabled. | -1 | INT | Yes | No |
tls.enabled | This parameter specifies whether a secure connection is enabled or not. When this parameter is set to true , the keystore.path and the keystore.password parameters are initialized. |
false | BOOL | Yes | No |
keystore.path | The file path to the location of the keystore. If a custom keystore is not specified, then the system uses the default keystore file - wso2carbon.jks in the ${carbon.home}/resources/security directory. |
${carbon.home}/resources/security/wso2carbon.jks | STRING | Yes | No |
keystore.password | The password for the keystore. A custom password can be specified if required. If no custom password is specified, then the system uses wso2carbon as the default password. |
wso2carbon | STRING | Yes | No |
Examples EXAMPLE 1
@Source(type = 'websocket-server', host='localhost', port='8025',
@map(type='xml'))
define stream Foo (attribute1 string, attribute2 int);
Under this configuration, events are received via the WebSocket server and they are passed to Foo
stream for processing.