Package io.pravega.client.stream
Interface IdempotentEventStreamWriter<Type>
-
- Type Parameters:
Type
- The type of events that go in this stream
- All Superinterfaces:
java.lang.AutoCloseable
public interface IdempotentEventStreamWriter<Type> extends java.lang.AutoCloseable
A writer can write events to a stream. Similar toEventStreamWriter
but with the ability to provide aSequence
onwriteEvent(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.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method 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.
-
-
-
Method Detail
-
writeEvent
java.util.concurrent.Future<java.lang.Void> writeEvent(java.lang.String routingKey, Sequence sequence, Type event)
Send an event to the stream. Events that are written should appear in the stream exactly once. Note that the implementation provides retry logic to handle connection failures and service host failures. This method takes aSequence
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.- Parameters:
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 stream- Returns:
- A future that will complete when the event has been durably stored on the configured number of replicas, and is available for readers to see. This future may complete exceptionally if this cannot happen, however these exceptions are not transient failures. Failures that occur as a result of connection drops or host death are handled internally with multiple retires and exponential backoff. So there is no need to attempt to retry in the event of an exception.
-
getConfig
EventWriterConfig getConfig()
Returns the configuration that this writer was create with.- Returns:
- Writer configuration
-
flush
void flush()
Block until all events that have been passed to writeEvent's corresponding futures have completed.
-
close
void close()
Calls flush and then closes the writer. (No further methods may be called)- Specified by:
close
in interfacejava.lang.AutoCloseable
-
-