Type
- The type of events that go in this streampublic interface EventStreamWriter<Type>
extends java.lang.AutoCloseable
Modifier and Type | Method and Description |
---|---|
void |
close()
Calls flush and then closes the writer.
|
void |
flush()
Block until all events that have been passed to writeEvent's corresponding futures have completed.
|
EventWriterConfig |
getConfig()
Returns the configuration that this writer was create with.
|
void |
noteTime(long timestamp)
Notes a time that can be seen by readers which read from this stream by
EventStreamReader.getCurrentTimeWindow(Stream) . |
java.util.concurrent.CompletableFuture<java.lang.Void> |
writeEvent(java.lang.String routingKey,
Type event)
Write an event to the stream.
|
java.util.concurrent.CompletableFuture<java.lang.Void> |
writeEvent(Type event)
Send an event to the stream.
|
java.util.concurrent.CompletableFuture<java.lang.Void> writeEvent(Type event)
Serializer.MAX_EVENT_SIZE
.
Note that the implementation provides retry logic to handle connection failures and service host
failures. Internal retries will not violate the exactly once semantic so it is better to rely on them
than to wrap this with custom retry logic.event
- The event to be written to the stream (Null is disallowed)java.util.concurrent.CompletableFuture<java.lang.Void> writeEvent(java.lang.String routingKey, Type event)
writeEvent(Object)
but provides a routingKey which is
used to specify ordering. Events written with the same routing key will be read by readers in exactly
the same order they were written. The maximum size of the serialized event supported is defined at
Serializer.MAX_EVENT_SIZE
.
Note that the implementation provides retry logic to handle connection failures and service
host failures. Internal retries will not violate the exactly once semantic so it is better to
rely on this than to wrap this method with custom retry logic.routingKey
- A free form string that is used to route messages to readers. Two events written with
the same routingKey are guaranteed to be read in order. Two events with different routing keys
may be read in parallel.event
- The event to be written to the stream (Null is disallowed)void noteTime(long timestamp)
EventStreamReader.getCurrentTimeWindow(Stream)
. The semantics or meaning of the timestamp
is left to the application. Readers might expect timestamps to be monotonic. So this is
recommended but not enforced.
There is no requirement to call this method. Never doing so will result in readers invoking
EventStreamReader.getCurrentTimeWindow(Stream)
receiving a null for both upper and lower times.
Calling this method can be automated by setting
EventWriterConfigBuilder#automaticallyNoteTime(boolean)
to true when creating a
writer.timestamp
- a timestamp that represents the current location in the stream.EventWriterConfig getConfig()
void flush()
void close()
close
in interface java.lang.AutoCloseable