Type
- The type of events that go in this streampublic interface EventStreamWriter<Type> extends AutoCloseable
Modifier and Type | Method and Description |
---|---|
Transaction<Type> |
beginTxn(long transactionTimeout,
long maxExecutionTime,
long scaleGracePeriod)
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(UUID transactionId)
Returns a previously created transaction.
|
CompletableFuture<Void> |
writeEvent(String routingKey,
Type event)
Write an event to the stream.
|
CompletableFuture<Void> |
writeEvent(Type event)
Send an event to the stream.
|
CompletableFuture<Void> writeEvent(Type event)
event
- The event to be written to the stream (Null is disallowed)CompletableFuture<Void> writeEvent(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(long transactionTimeout, long maxExecutionTime, long scaleGracePeriod)
transactionTimeout
- The number of milliseconds after now, that if commit has not been called by, the
transaction may be aborted. Note that this should not be set unnecessarily high, as having long running
transactions may interfere with a streams to scale in response to a change in rate. For this reason
streams may configure an upper limit to this value.maxExecutionTime
- The maximum amount of time, in milliseconds, until which transaction timeout may be
increased via the pingTransaction API.scaleGracePeriod
- The maximum amount of time, in milliseconds, until which transacition may remain active,
after a scale operation has been initiated on the underlying stream.Transaction<Type> getTxn(UUID transactionId)
transactionId
- The result retained from calling Transaction.getTxnId()
EventWriterConfig getConfig()
void flush()
void close()
close
in interface AutoCloseable