Type
- The type of events that go in this streampublic interface IdempotentEventStreamWriter<Type>
extends java.lang.AutoCloseable
EventStreamWriter
but with the
ability to provide a Sequence
on writeEvent(String, Sequence, Object)
to prevent
duplicates, in the event that the writer process crashes and restarts.
This class is safe to use across threads, but doing so will not increase performance.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.
|
java.util.concurrent.Future<java.lang.Void> |
writeEvent(java.lang.String routingKey,
Sequence sequence,
Type event)
Send an event to the stream.
|
java.util.concurrent.Future<java.lang.Void> writeEvent(java.lang.String routingKey, Sequence sequence, Type event)
Sequence
on each event for the purposes of preventing duplicates.
Sequences are user defined and assumed to be monotonically increasing. If a sequence is
passed to writeEvent that is less or equal to a sequence previously passed to writeEvent, the
event is acked without wiring it to the stream.
This allows for applications with a deterministic writer to de-dup events in the event that
the writer dies.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.sequence
- An ever increasing sequence. If this method is called with a lower sequence
the event will not be written.event
- The event to be written to the streamEventWriterConfig getConfig()
void flush()
void close()
close
in interface java.lang.AutoCloseable