Interface RReliableQueueAsync<V>

All Superinterfaces:
RExpirableAsync, RObjectAsync
All Known Subinterfaces:
RReliableQueue<V>

public interface RReliableQueueAsync<V> extends RExpirableAsync
Reliable queue asynchronous implementation based on Stream object.

Unlike regular queues, this implementation provides features like:

  • Message acknowledgment to confirm successful processing
  • Message negative acknowledgment to redeliver a message or delete it if DLQ is not defined
  • Redundancy and synchronous replication
  • Deduplication by id or hash within a defined time interval
  • Bulk operations
  • Configurable queue size limit
  • Configurable message size limit
  • Configurable message expiration timeout
  • Configurable message visibility timeout
  • Configurable message priority
  • Configurable message delay
  • Configurable message delivery limit
  • Automatic redelivery of unacknowledged messages
  • Dead letter queue support for failed message handling
Author:
Nikita Koksharov
  • Method Details

    • setConfigAsync

      RFuture<Void> setConfigAsync(QueueConfig config)
      Sets the configuration for this reliable queue.
      Parameters:
      config - the queue configuration to apply
    • setConfigIfAbsentAsync

      RFuture<Boolean> setConfigIfAbsentAsync(QueueConfig config)
      Attempts to set the configuration for this reliable queue.

      This method only applies the configuration if no configuration has been set previously.

      Parameters:
      config - the queue configuration to apply
      Returns:
      true if the configuration was successfully applied, false if a configuration already exists
    • sizeAsync

      RFuture<Integer> sizeAsync()
      Returns the total number of messages in the queue, including messages in all states (ready, delayed, and unacknowledged).
      Returns:
      the total number of messages
    • countDelayedMessagesAsync

      RFuture<Integer> countDelayedMessagesAsync()
      Returns the number of delayed messages in the queue.

      Delayed messages are those scheduled for future delivery and not yet available for consumption.

      Returns:
      the number of delayed messages
    • countUnacknowledgedMessagesAsync

      RFuture<Integer> countUnacknowledgedMessagesAsync()
      Returns the number of unacknowledged messages in the queue.

      Unacknowledged messages are those that have been delivered to consumers but not yet acknowledged as successfully processed.

      Returns:
      the number of unacknowledged messages
    • clearAsync

      RFuture<Boolean> clearAsync()
      Removes all messages from the queue.

      This operation clears messages in all states (ready, delayed, and unacknowledged).

      Returns:
      true if the queue existed and has been cleared, otherwise false
    • pollAsync

      RFuture<Message<V>> pollAsync()
      Retrieves and removes the head of this queue, or returns null if this queue is empty.

      The retrieved message remains unacknowledged until explicitly acknowledged using the acknowledgeAsync(QueueAckArgs) or negativeAcknowledgeAsync(QueueNegativeAckArgs) method.

      Returns:
      the message in the head of this queue, or null if this queue is empty
    • pollAsync

      RFuture<Message<V>> pollAsync(QueuePollArgs args)
      Retrieves and removes the head of this queue with the specified polling arguments.

      The retrieved message remains unacknowledged until explicitly acknowledged using the acknowledgeAsync(QueueAckArgs) or negativeAcknowledgeAsync(QueueNegativeAckArgs) method.

      Parameters:
      args - polling arguments
      Returns:
      the message in the head of this queue, or null if this queue is empty
    • pollManyAsync

      RFuture<List<Message<V>>> pollManyAsync(QueuePollArgs pargs)
      Retrieves and removes multiple messages from the queue with the specified polling arguments.

      This batch operation is more efficient than polling messages individually.

      The retrieved messages remain unacknowledged until explicitly acknowledged using the acknowledgeAsync(QueueAckArgs) or negativeAcknowledgeAsync(QueueNegativeAckArgs) method.

      Parameters:
      pargs - polling arguments
      Returns:
      a list of retrieved messages
    • acknowledgeAsync

      RFuture<Void> acknowledgeAsync(QueueAckArgs args)
      Acknowledges the successful processing of a message.

      Once acknowledged, a message is permanently removed from the queue and will not be redelivered.

      Parameters:
      args - acknowledgment arguments
    • containsAsync

      RFuture<Boolean> containsAsync(String id)
      Checks if the queue contains a message with the specified ID.
      Parameters:
      id - the message ID to check
      Returns:
      true if a message with the specified ID exists in the queue, false otherwise
    • containsManyAsync

      RFuture<Integer> containsManyAsync(String... ids)
      Checks if the queue contains messages with the specified IDs.
      Parameters:
      ids - the message IDs to check
      Returns:
      the number of matching messages found in the queue
    • removeAsync

      RFuture<Boolean> removeAsync(QueueRemoveArgs args)
      Removes a specific message from the queue.

      This operation can remove messages in any state (ready, delayed, or unacknowledged).

      Parameters:
      args - removal arguments
      Returns:
      true if the message was successfully removed, false if the message was not found
    • removeManyAsync

      RFuture<Integer> removeManyAsync(QueueRemoveArgs args)
      Removes multiple messages from the queue in a single operation.
      Parameters:
      args - removal arguments
      Returns:
      the number of messages successfully removed
    • moveAsync

      RFuture<Integer> moveAsync(QueueMoveArgs args)
      Moves messages from the queue to the end of the destination queue.
      Parameters:
      args - move arguments
      Returns:
      the number of messages successfully moved
    • addAsync

      RFuture<Message<V>> addAsync(QueueAddArgs<V> params)
      Adds a message to the queue with the specified parameters.

      Returns null if the message hasn't been added for one of the following reasons:

      • Due to message deduplication by id or hash
      • Due to configured queue size limit and queue is full
      Parameters:
      params - parameters for the message to be added
      Returns:
      the added message with its assigned ID and metadata
    • addManyAsync

      RFuture<List<Message<V>>> addManyAsync(QueueAddArgs<V> params)
      Adds multiple messages to the queue in a single operation.

      This batch operation is more efficient than adding messages individually.

      Messages may not be added for one of the following reasons:

      • Due to message deduplication by id or hash
      • Due to configured queue size limit and queue is full
      Parameters:
      params - parameters for the messages to be added
      Returns:
      a list of added messages with their assigned IDs and metadata
    • getDeadLetterQueueSourcesAsync

      RFuture<Set<String>> getDeadLetterQueueSourcesAsync()
      Returns the names of source queues which uses this reliable queue as dead letter queue.

      This only applies if this queue is configured as a dead letter queue in the source queue configurations.

      Returns:
      a set of source queue names
    • listAllAsync

      RFuture<List<Message<V>>> listAllAsync()
      Returns all messages in the queue, ready to be retrieved by the poll() command, without removing them.

      This operation is useful for inspection and debugging purposes.

      Returns:
      a list of all messages in the queue
    • listAllAsync

      RFuture<List<Message<V>>> listAllAsync(Codec headersCodec)
      Returns all messages in the queue, ready to be retrieved by the poll() command, using the specified codec for message header values.
      Parameters:
      headersCodec - the codec to use for deserializing message header values
      Returns:
      a list of all messages in the queue
    • getAsync

      RFuture<Message<V>> getAsync(String id)
      Returns message by id
      Parameters:
      id - message id
      Returns:
      message
    • getAsync

      RFuture<Message<V>> getAsync(Codec headersCodec, String id)
      Returns message by id applying specified codec to headers
      Parameters:
      headersCodec - codec for headers
      id - message id
      Returns:
      message
    • getAllAsync

      RFuture<List<Message<V>>> getAllAsync(String... ids)
      Returns messages by ids
      Parameters:
      ids - message ids
      Returns:
      message
    • getAllAsync

      RFuture<List<Message<V>>> getAllAsync(Codec headersCodec, String... ids)
      Returns messages by ids applying specified codec to headers
      Parameters:
      headersCodec - codec for headers
      ids - message ids
      Returns:
      message
    • negativeAcknowledgeAsync

      RFuture<Void> negativeAcknowledgeAsync(QueueNegativeAckArgs args)
      Explicitly marks a message as failed or rejected.
      Parameters:
      args - arguments specifying the message to negatively acknowledge
    • addListenerAsync

      RFuture<String> addListenerAsync(QueueEventListener listener)
      Adds queue listener
      Parameters:
      listener - entry listener
      Returns:
      listener id
      See Also:
    • removeListenerAsync

      RFuture<Void> removeListenerAsync(String id)
      Removes map entry listener
      Parameters:
      id - listener id
    • disableOperationAsync

      RFuture<Void> disableOperationAsync(QueueOperation operation)
      Disables a queue operation
      Parameters:
      operation - queue operation
      Returns:
      void
    • enableOperationAsync

      RFuture<Void> enableOperationAsync(QueueOperation operation)
      Enables a queue operation
      Parameters:
      operation - queue operation
      Returns:
      void