Network¶
The network
source opens server socket and receives data from network using UDP or TCP protocol.
NetworkSourceConfig<String> config = NetworkSourceConfigBuilder
.<String>builder()
.withAddress("0.0.0.0", 123)
.withType(NetworkType.UDP)
.withExceptionHandler(...)
.withDecoder(Decoders.toLinesDecoder())
.addSocketOptionsEntry("SO_LINGER", "1")
.addSocketOptionsEntry("TCP_NODELAY", "true")
.build();
source:
network:
type: udp
address: "0.0.0.0:34567"
socketOptions:
SO_RCVBUF: 65536
SO_TIMEOUT: 1000
Properties¶
address
¶
The address to bind server socket to. If the IP/host is omitted then 0.0.0.0
is assumed.
The IP is useful if the host has multiple network interfaces.
Required.
Type: object
Default value: 0.0.0.0
Fields of address
:
address.host
¶
Type: string
address.port
¶
Type: number
address.hasBracketlessColons
¶
Type: boolean
type
¶
Specifies the network protocol type. Required.
Type: object
Supported values: tcp
, udp
.
decoder
¶
Decoder to be applied to received data.
Examples are decoders that convert incoming data to string or to byte arrays.
For ready-to-use decoders check org.voltdb.stream.api.network.Decoders
defined in
volt-stream-connectors-api
.
Required.
Type: object
socketOptions
¶
Configures operating system options to be applied to the server socket.
Supported values are: SO_SNDBUF
, SO_RCVBUF
, SO_TIMEOUT
, SO_KEEPALIVE
, SO_LINGER
, SO_BACKLOG
, TCP_NODELAY
.
Type: object
exceptionHandler
¶
Custom exception handler enabling interception of all errors related to this source.
Type: object
Java dependency management¶
Add this declaration to your dependency management system to access the configuration DSL for this plugin in Java.
<dependency>
<groupId>org.voltdb</groupId>
<artifactId>volt-stream-plugin-network-api</artifactId>
<version>1.4.0</version>
</dependency>
implementation group: 'org.voltdb', name: 'volt-stream-plugin-network-api', version: '1.4.0'
Usage Examples¶
stream
.withName("Read data from TCP socket and print to stdout")
.consumeFromSource(
NetworkSourceConfigBuilder.<String>builder()
.withAddressPort(42)
.withType(NetworkType.TCP)
.withDecoder(Decoders.toLinesDecoder())
)
.terminateWithSink(Sinks.stdout());