public class KafkaMessageStream extends Object implements TrackingEventStream
KafkaTrackingToken
Records are fetched from kafka and stored in-memory
buffer.
This is not thread safe
Constructor and Description |
---|
KafkaMessageStream(Buffer<KafkaEventMessage> buffer,
Runnable closeHandler) |
Modifier and Type | Method and Description |
---|---|
void |
close() |
boolean |
hasNextAvailable(int timeout,
TimeUnit unit)
Checks whether or not the next message in the stream is available.
|
TrackedEventMessage<?> |
nextAvailable()
Returns the next available message in the stream.
|
Optional<TrackedEventMessage<?>> |
peek()
Checks whether or not the next message in the stream is immediately available.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
asStream, hasNextAvailable
public KafkaMessageStream(Buffer<KafkaEventMessage> buffer, Runnable closeHandler)
public Optional<TrackedEventMessage<?>> peek()
MessageStream
peek
in interface MessageStream<TrackedEventMessage<?>>
public boolean hasNextAvailable(int timeout, TimeUnit unit)
MessageStream
true
or until the given timeout
expires, returning
false
.
To check if the stream has messages available now, pass a zero timeout
.
hasNextAvailable
in interface MessageStream<TrackedEventMessage<?>>
timeout
- the maximum number of time units to wait for messages to become availableunit
- the time unit for the timeoutpublic TrackedEventMessage<?> nextAvailable()
MessageStream
MessageStream.hasNextAvailable()
with or without a timeout to check if the stream has available messages before calling this method.nextAvailable
in interface MessageStream<TrackedEventMessage<?>>
public void close()
close
in interface AutoCloseable
close
in interface MessageStream<TrackedEventMessage<?>>
Copyright © 2010–2018. All rights reserved.