public interface EventStreamClientFactory
extends java.lang.AutoCloseable
Events that are written to a stream can be read by a reader. All events can be processed with
exactly once semantics provided the reader has the ability to restore to the correct position
upon failure. See EventRead.getPosition()
A note on ordering: Events inside of a stream have an order, but may need to be divided between
multiple readers for scaling. In order to process events in parallel on different hosts and still
have some ordering guarantees; events written to a stream have a routingKey see
EventStreamWriter.writeEvent(String, Object)
. Events with the same routing key are
delivered to a reader in order serially (i.e. They must go the the same reader or its
replacement). However because ReaderGroup
s process events in parallel there is no
ordering between events sent to different routing keys because these may end up on different
readers.
A note on scaling: Because a stream can grow in its event rate, streams are divided into Segments. For the most part this is an implementation detail. However its worth understanding that the way a stream is divided between multiple readers in a group that wish to split the messages between them is by giving different segments to different readers.
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the client factory.
|
<T> EventStreamWriter<T> |
createEventWriter(java.lang.String streamName,
Serializer<T> s,
EventWriterConfig config)
Creates a new writer that can write to the specified stream.
|
<T> EventStreamWriter<T> |
createEventWriter(java.lang.String writerId,
java.lang.String streamName,
Serializer<T> s,
EventWriterConfig config)
Creates a new writer that can write to the specified stream.
|
<T> EventStreamReader<T> |
createReader(java.lang.String readerId,
java.lang.String readerGroup,
Serializer<T> s,
ReaderConfig config)
Creates (or recreates) a new reader that is part of a
ReaderGroup . |
<T> TransactionalEventStreamWriter<T> |
createTransactionalEventWriter(java.lang.String streamName,
Serializer<T> s,
EventWriterConfig config)
Creates a new transactional writer that can write to the specified stream atomically.
|
<T> TransactionalEventStreamWriter<T> |
createTransactionalEventWriter(java.lang.String writerId,
java.lang.String streamName,
Serializer<T> s,
EventWriterConfig config)
Creates a new transactional writer that can write to the specified stream atomically.
|
static EventStreamClientFactory |
withScope(java.lang.String scope,
ClientConfig config)
Creates a new instance of Client Factory.
|
static EventStreamClientFactory withScope(java.lang.String scope, ClientConfig config)
scope
- The scope string.config
- Configuration for the client.<T> EventStreamWriter<T> createEventWriter(java.lang.String streamName, Serializer<T> s, EventWriterConfig config)
T
- The type of events.streamName
- The name of the stream to write to.s
- The Serializer.config
- The writer configuration.<T> EventStreamWriter<T> createEventWriter(java.lang.String writerId, java.lang.String streamName, Serializer<T> s, EventWriterConfig config)
T
- The type of events.writerId
- An name which identifies this writer.streamName
- The name of the stream to write to.s
- The Serializer.config
- The writer configuration.<T> TransactionalEventStreamWriter<T> createTransactionalEventWriter(java.lang.String writerId, java.lang.String streamName, Serializer<T> s, EventWriterConfig config)
T
- The type of events.writerId
- An name which identifies this writer.streamName
- The name of the stream to write to.config
- The writer configuration.s
- The Serializer.<T> TransactionalEventStreamWriter<T> createTransactionalEventWriter(java.lang.String streamName, Serializer<T> s, EventWriterConfig config)
T
- The type of events.streamName
- The name of the stream to write to.config
- The writer configuration.s
- The Serializer.<T> EventStreamReader<T> createReader(java.lang.String readerId, java.lang.String readerGroup, Serializer<T> s, ReaderConfig config)
ReaderGroup
. The reader
will join the group and the members of the group will automatically rebalance among
themselves.
In the event that the reader dies, the method ReaderGroup.readerOffline(String, Position)
should be called, passing the last position of the reader (Usually done by storing the
position along with the output when it is processed.) Which will trigger redistribute the
events among the remaining readers.
Note that calling reader offline while the reader is still online may result in multiple readers within the group receiving the same events.
T
- The type of events.readerId
- A unique name (within the group) for this reader.readerGroup
- The name of the group to join.s
- The serializer for events.config
- The reader's configuration.void close()
close
in interface java.lang.AutoCloseable
AutoCloseable.close()