Class EventBuffer
java.lang.Object
org.axonframework.axonserver.connector.event.axon.EventBuffer
- All Implemented Interfaces:
AutoCloseable,BlockingStream<TrackedEventMessage<?>>,TrackingEventStream
Client-side buffer of messages received from the server. Once consumed from this buffer, the client is notified of a
permit being consumed, potentially triggering a permit refresh, if flow control is enabled.
This class is intended for internal use. Be cautious.
- Since:
- 4.0
- Author:
- Marc Gathier, Allard Buijze
-
Constructor Summary
ConstructorsConstructorDescriptionEventBuffer(io.axoniq.axonserver.connector.event.EventStream delegate, EventUpcaster upcasterChain, Serializer serializer, boolean disableIgnoredEventFiltering) Initializes an Event Buffer, passing messages through givenupcasterChainand deserializing events using givenserializer. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()booleanhasNextAvailable(int timeout, TimeUnit timeUnit) Checks whether or not the next message in the stream is available.Returns the next available message in the stream.peek()Checks whether or not the next message in the stream is immediately available.booleansetOnAvailableCallback(Runnable callback) Set acallbackto be invoked once new messages are available on this stream.voidskipMessagesWithPayloadTypeOf(TrackedEventMessage<?> ignoredMessage) Report the stream that a specific message was ignored by the consumer.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.axonframework.common.stream.BlockingStream
asStream, hasNextAvailable
-
Constructor Details
-
EventBuffer
public EventBuffer(io.axoniq.axonserver.connector.event.EventStream delegate, EventUpcaster upcasterChain, Serializer serializer, boolean disableIgnoredEventFiltering) Initializes an Event Buffer, passing messages through givenupcasterChainand deserializing events using givenserializer.- Parameters:
delegate- theEventStreamto 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 buffer
-
-
Method Details
-
skipMessagesWithPayloadTypeOf
Report the stream that a specific message was ignored by the consumer. Stream implementation can use this information for instance to filter messages with the same type of payload.This implementation removes events from the stream based on the payload type of the given message.
- Specified by:
skipMessagesWithPayloadTypeOfin interfaceBlockingStream<TrackedEventMessage<?>>- Parameters:
ignoredMessage- the message containing the payload to exclude from the stream
-
peek
Description copied from interface:BlockingStreamChecks whether or not the next message in the stream is immediately available. If so, an Optional with the next message is returned (without moving the stream pointer), otherwise an empty Optional is returned.- Specified by:
peekin interfaceBlockingStream<TrackedEventMessage<?>>- Returns:
- the next event if immediately available
-
hasNextAvailable
Description copied from interface:BlockingStreamChecks whether or not the next message in the stream is available. If a message is available when this method is invoked this method returns immediately. If not, this method will block until a message becomes available, returningtrueor until the giventimeoutexpires, returningfalse.To check if the stream has messages available now, pass a zero
timeout.- Specified by:
hasNextAvailablein interfaceBlockingStream<TrackedEventMessage<?>>- Parameters:
timeout- the maximum number of time units to wait for messages to become availabletimeUnit- the time unit for the timeout- Returns:
- true if a message is available or becomes available before the given timeout, false otherwise
- Throws:
InterruptedException- when the thread is interrupted before the indicated time is up
-
nextAvailable
Description copied from interface:BlockingStreamReturns the next available message in the stream. Note that this method blocks for as long as there are no available messages in the stream. In case this blocking behavior is not desired useBlockingStream.hasNextAvailable()with or without a timeout to check if the stream has available messages before calling this method.- Specified by:
nextAvailablein interfaceBlockingStream<TrackedEventMessage<?>>- Returns:
- the next available message
- Throws:
InterruptedException- when the thread is interrupted before the next message is returned
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceBlockingStream<TrackedEventMessage<?>>
-
setOnAvailableCallback
Description copied from interface:BlockingStreamSet acallbackto be invoked once new messages are available on this stream. Returnstrueif this functionality is supported andfalseotherwise. Whentrueis returned, the callee can expect thecallbackto be invoked immediately.Note that returning
falsedoes not define the givencallbackis never invoked. If the callee needs to be certain thecallbackis never invoked in case offalse, a no-opRunnableshould be provided.- Specified by:
setOnAvailableCallbackin interfaceBlockingStream<TrackedEventMessage<?>>- Parameters:
callback- aRunnable- Returns:
trueif on available callback is supported and can thus be waited on,false otherwise
-