Class DefaultQueue<T>
java.lang.Object
io.aleph0.yap.core.transport.queue.DefaultQueue<T>
- All Implemented Interfaces:
Measureable<Queue.Metrics>,Queue<T>
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic final record -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> DefaultQueue.Builder<T> builder()Non-destructive check of the metrics.Destructive read of the metrics.booleanreceive()Receives a message from the queue, waiting if necessary.Receives a message from the queue, waiting if necessary.Attempts to receive a message from the queue.
-
Constructor Details
-
DefaultQueue
-
-
Method Details
-
builder
-
tryReceive
Description copied from interface:QueueAttempts to receive a message from the queue. This method will return immediately, even if there are no messages available in the queue. Returnsnullif the queue is empty, whethere it is closed or not, so users must not conclude that the queue is closed and drained from this method returningnull.- Specified by:
tryReceivein interfaceQueue<T>- Returns:
- the message received from the queue, or
nullif the queue is empty
-
receive
Description copied from interface:QueueReceives a message from the queue, waiting if necessary. This method will block until a message is received from the queue or the timeout expires. If the queue is closed and drained, this method will returnnull. Users may conclude that the queue is closed and drained from this method returningnull.- Specified by:
receivein interfaceQueue<T>- Parameters:
timeout- the maximum time to wait for a message to be received- Returns:
- the message received from the queue, or
nullif the queue is closed and drained - Throws:
InterruptedException- if the thread is interrupted while waitingTimeoutException- if the wait times out before a message is received
-
receive
Description copied from interface:QueueReceives a message from the queue, waiting if necessary. This method will block until a message is received from the queue. If the queue is closed and drained, this method will returnnull. Users may conclude that the queue is closed and drained from this method returningnull.- Specified by:
receivein interfaceQueue<T>- Returns:
- the message received from the queue, or
nullif the queue is closed and drained - Throws:
InterruptedException- if the thread is interrupted while waiting
-
isDrained
-
checkMetrics
Description copied from interface:MeasureableNon-destructive check of the metrics. This should be used to check the state of metrics without clearing them, for example in aTaskController.- Specified by:
checkMetricsin interfaceMeasureable<T>- Returns:
- the metrics
-
flushMetrics
Description copied from interface:MeasureableDestructive read of the metrics. This should be used to check and reset the state of metrics, for example by the metrics checking thread.- Specified by:
flushMetricsin interfaceMeasureable<T>- Returns:
- the metrics
-