public class EventBuffer extends Object implements TrackingEventStream
This class is intended for internal use. Be cautious.
Constructor and Description |
---|
EventBuffer(io.axoniq.axonserver.connector.event.EventStream delegate,
EventUpcaster upcasterChain,
Serializer serializer,
boolean disableIgnoredEventFiltering)
Initializes an Event Buffer, passing messages through given
upcasterChain and deserializing events using
given serializer . |
Modifier and Type | Method and Description |
---|---|
void |
close() |
boolean |
hasNextAvailable(int timeout,
TimeUnit timeUnit)
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.
|
boolean |
setOnAvailableCallback(Runnable callback)
Set a
callback to be invoked once new messages are available on this stream. |
void |
skipMessagesWithPayloadTypeOf(TrackedEventMessage<?> ignoredMessage)
Report the stream that a specific message was ignored by the consumer.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
asStream, hasNextAvailable
public EventBuffer(io.axoniq.axonserver.connector.event.EventStream delegate, EventUpcaster upcasterChain, Serializer serializer, boolean disableIgnoredEventFiltering)
upcasterChain
and deserializing events using
given serializer
.delegate
- the EventStream
to delegate operations toupcasterChain
- the upcasterChain to translate serialized representations before
deserializingserializer
- the serializer capable of deserializing incoming messagesdisableIgnoredEventFiltering
- specifying whether events should or should not be included in the bufferpublic void skipMessagesWithPayloadTypeOf(TrackedEventMessage<?> ignoredMessage)
This implementation removes events from the stream based on the payload type of the given message.
skipMessagesWithPayloadTypeOf
in interface BlockingStream<TrackedEventMessage<?>>
ignoredMessage
- the message containing the payload to exclude from the streampublic Optional<TrackedEventMessage<?>> peek()
BlockingStream
peek
in interface BlockingStream<TrackedEventMessage<?>>
public boolean hasNextAvailable(int timeout, TimeUnit timeUnit)
BlockingStream
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 BlockingStream<TrackedEventMessage<?>>
timeout
- the maximum number of time units to wait for messages to become availabletimeUnit
- the time unit for the timeoutpublic TrackedEventMessage<?> nextAvailable()
BlockingStream
BlockingStream.hasNextAvailable()
with or without a timeout to check if the stream has available messages before calling this method.nextAvailable
in interface BlockingStream<TrackedEventMessage<?>>
public void close()
close
in interface AutoCloseable
close
in interface BlockingStream<TrackedEventMessage<?>>
public boolean setOnAvailableCallback(Runnable callback)
BlockingStream
callback
to be invoked once new messages are available on this stream. Returns true
if this
functionality is supported and false
otherwise. When true
is returned, the callee can expect the
callback
to be invoked immediately.
Note that returning false
does not define the given callback
is never invoked. If the callee
needs to be certain the callback
is never invoked in case of false
, a no-op Runnable
should be provided.
setOnAvailableCallback
in interface BlockingStream<TrackedEventMessage<?>>
callback
- a Runnable
true
if on available callback is supported and can thus be waited on, false otherwise
Copyright © 2010–2024. All rights reserved.