Type
- The type of events that go in this streampublic interface EventStreamWriter<Type>
extends java.lang.AutoCloseable
Modifier and Type | Method and Description |
---|---|
Transaction<Type> |
beginTxn()
Start a new transaction on this stream.
|
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.
|
Transaction<Type> |
getTxn(java.util.UUID transactionId)
Returns a previously created transaction.
|
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)
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.
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)Transaction<Type> beginTxn()
EventWriterConfig#getTransactionTimeoutTime()
.Transaction<Type> getTxn(java.util.UUID transactionId)
transactionId
- The result retained from calling Transaction.getTxnId()
EventWriterConfig getConfig()
void flush()
void close()
close
in interface java.lang.AutoCloseable