Http¶
The http sink connects and sends http(s) requests to configured downstream HTTP(s) server over single connection per worker thread.
If server doesn't close the connection, it will be reused for subsequent requests.
If server is not available, sink will keep on trying to re-connect each time new event arrives. In other words, if there are not events in the pipeline, this sink will not try to connect.
This sink can execute only POST, PUT, PATCH or DELETE requests.
.consumeFromSource(...)
.terminateWithSink(HttpSinkConfigBuilder.builder()
.withHttpClient(value)
.withRetryConfiguration(builder -> builder
.withRetries(value)
.withBackoffDelay(value)
.withMaxBackoffDelay(value)
)
.withExceptionHandler(value)
)
sink:
http:
httpClient: value
retryConfiguration:
retries: value
backoffDelay: value
maxBackoffDelay: value
exceptionHandler: value
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.6.0</version>
</dependency>
implementation group: 'org.voltdb', name: 'volt-stream-plugin-http-api', version: '1.6.0'
Properties¶
httpClient¶
Http client reference Required.
Type: object
retryConfiguration¶
Retry configuration of failed request.
Type: object
Fields of retryConfiguration:
retryConfiguration.retries¶
Number of retry attempts after a request failure.
Type: number
Default value: 3
retryConfiguration.backoffDelay¶
Initial delay before the first retry attempt.
Type: object
Default value: PT0.2S
retryConfiguration.maxBackoffDelay¶
Maximum delay between consecutive retry attempts.
Type: object
Default value: PT3S
exceptionHandler¶
Custom exception handler enabling interception of all errors related to this sink.
Type: object
JSON Schema¶
You can validate or explore the configuration using its JSON Schema.
Usage Examples¶
stream
.withName("Read data from HTTP server and print to stdout")
.configureResource("a-http-client", HttpClientResourceConfigBuilder.builder()
.withAddress(HostAndPort.fromParts("localhost", 9090))
...
)
.consumeFromSource(...)
.processWith(event -> new HttpRequest(...))
.terminateWithSink(HttpSinkConfigBuilder.builder()
.withHttpClientName("a-http-client")
.withHeaders(Map.of("Content-Type", "application/json"))
);
stream
.withName("Read data from HTTP server and print to stdout")
.consumeFromSource(...)
.processWith(event -> new HttpRequest(...))
.terminateWithSink(HttpSinkConfigBuilder.builder()
// the name of the resource is `httpClient`
.withHttpClientBuilder(builder -> {
builder.withAddress(HostAndPort.fromParts("localhost", 9090))
})
.withHeaders(Map.of("Content-Type", "application/json"))
);
resources:
- name: a-http-client
http-client:
address: localhost:32112
...
source:
...
sink:
http:
httpClientReference: a-http-client
headers:
Content-Type: application/json
the http-client resource can be configured inline like
source:
...
sink:
http:
httpClient:
address: localhost:32112
...
headers:
Content-Type: application/json