API Docs - v2.0.18
Sink
tcp (Sink)
A Siddhi application can be configured to publish events via the TCP transport by adding the @Sink(type = 'tcp') annotation at the top of an event stream definition.
Syntax
@sink(type="tcp", url="<STRING>", sync="<STRING>", tcp.no.delay="<BOOL>", keep.alive="<BOOL>", worker.threads="<INT|LONG>", @map(...)))
QUERY PARAMETERS
Name | Description | Default Value | Possible Data Types | Optional | Dynamic |
---|---|---|---|---|---|
url | The URL to which outgoing events should be published via TCP. The URL should adhere to tcp://<host>:<port>/<context> format. |
STRING | No | No | |
sync | This parameter defines whether the events should be published in a synchronized manner or not. If sync = 'true', then the worker will wait for the ack after sending the message. Else it will not wait for an ack. |
false | STRING | Yes | Yes |
tcp.no.delay | This is to specify whether to disable Nagle algorithm during message passing. If tcp.no.delay = 'true', the execution of Nagle algorithm will be disabled in the underlying TCP logic. Hence there will be no delay between two successive writes to the TCP connection. Else there can be a constant ack delay. |
true | BOOL | Yes | No |
keep.alive | This property defines whether the server should be kept alive when there are no connections available. | true | BOOL | Yes | No |
worker.threads | Number of threads to publish events. | 10 | INT LONG |
Yes | No |
Examples EXAMPLE 1
@Sink(type = 'tcp', url='tcp://localhost:8080/abc', sync='true'
@map(type='binary'))
define stream Foo (attribute1 string, attribute2 int);
A sink of type 'tcp' has been defined.
All events arriving at Foo stream via TCP transport will be sent to the url tcp://localhost:8080/abc in a synchronous manner.
Source
tcp (Source)
A Siddhi application can be configured to receive events via the TCP transport by adding the @Source(type = 'tcp') annotation at the top of an event stream definition.
When this is defined the associated stream will receive events from the TCP transport on the host and port defined in the system.
Syntax
@source(type="tcp", context="<STRING>", @map(...)))
QUERY PARAMETERS
Name | Description | Default Value | Possible Data Types | Optional | Dynamic |
---|---|---|---|---|---|
context | The URL 'context' that should be used to receive the events. | STRING | Yes | No |
System Parameters
Name | Description | Default Value | Possible Parameters |
---|---|---|---|
host | Tcp server host. | 0.0.0.0 | Any valid host or IP |
port | Tcp server port. | 9892 | Any integer representing valid port |
receiver.threads | Number of threads to receive connections. | 10 | Any positive integer |
worker.threads | Number of threads to serve events. | 10 | Any positive integer |
tcp.no.delay | This is to specify whether to disable Nagle algorithm during message passing. If tcp.no.delay = 'true', the execution of Nagle algorithm will be disabled in the underlying TCP logic. Hence there will be no delay between two successive writes to the TCP connection. Else there can be a constant ack delay. |
true | true false |
keep.alive | This property defines whether the server should be kept alive when there are no connections available. | true | true false |
Examples EXAMPLE 1
@Source(type = 'tcp', context='abc', @map(type='binary'))
define stream Foo (attribute1 string, attribute2 int );
Under this configuration, events are received via the TCP transport on default host,port, abc
context, and they are passed to Foo
stream for processing.