Skip to content

Http

The http listens for incoming connections, accepting HTTP/1.1 POST requests and processing them accordingly.

HttpSourceConfig<CharSequence> config = HttpSourceConfigBuilder
         .<CharSequence>builder()
         .withAddress("0.0.0.0", 8080)
         .withExceptionHandler(...)
         .withDecoder(Decoders.toCharSequenceDecoder())
         .build();
source:
   http:
     address: '0.0.0.0:8080'
     path: "/basket"
     expectedContentTypes:
     - application/json
     - text/plain
     headers:
     - Content-Type
     - CustomHeader
     readIdleTimeout: PT1M

Properties

address

If no address is provided, the server defaults to 0.0.0.0, which binds it to all available 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

decoder

Decoder applied to incoming data. Converts input into a usable format. For built-in decoder implementations, see org.voltdb.stream.api.network.Decoders.

Required.

Type: object

path

The URI path on which the HTTP server listens for incoming requests. For example, '/' for the root context, or '/basket' for a specific subpath.

Type: string

Default value: /

headers

A set of headers extracted from the HTTP request, if present, to be propagated further down the pipeline.

Type: array

maxContentSize

Specifies the maximum size (in bytes) of incoming content that the server will accept. The default limit is 1 MB to prevent excessive memory usage.

Type: number

Default value: 1048576

expectedContentTypes

List of accepted content types. Defaults to accepting any type if not specified.

Type: array

readIdleTimeout

Read idle timeout. Closes the connection if no inbound data is received.

Type: object

Default value: PT1M

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-http-api</artifactId>
    <version>1.4.0</version>
</dependency>
implementation group: 'org.voltdb', name: 'volt-stream-plugin-http-api', version: '1.4.0'

Usage Examples

 stream
        .withName("Read data from HTTP server and print to stdout")
        .consumeFromSource(
            HttpSourceConfigBuilder.builder()
                .withDecoder(Decoders.toCharSequenceDecoder())
                .withAddress(HostAndPort.fromParts("0.0.0.0", 8080))
                .withPath("/basket")
                .withExpectedContentTypes("application/json", "text/plain")
                .withHeaders("Content-Type", "CustomHeader")
                .withReadIdleTimeout(Duration.ofMillis(1))
        )
        .terminateWithSink(Sinks.stdout());