Interface QueuePollArgs

All Superinterfaces:
SyncArgs<QueuePollArgs>
All Known Implementing Classes:
QueuePollParams

public interface QueuePollArgs extends SyncArgs<QueuePollArgs>
Arguments for queue polling operations.

Use the defaults() factory method to create a new instance with default settings.

Example usage:

 QueuePollArgs args = QueuePollArgs.defaults()
     .acknowledgeMode(AcknowledgeMode.MANUAL)
     .timeout(Duration.ofSeconds(5))
     .count(10);
 
Author:
Nikita Koksharov
  • Method Details

    • defaults

      static QueuePollArgs defaults()
      Creates a new instance of QueuePollArgs with default settings.
      Returns:
      arguments object
    • acknowledgeMode

      QueuePollArgs acknowledgeMode(AcknowledgeMode mode)
      Sets the acknowledgment mode for message processing.

      The acknowledgment mode determines how messages are acknowledged after retrieval:

      • AcknowledgeMode.AUTO - Messages are automatically acknowledged after delivery
      • AcknowledgeMode.MANUAL - Messages must be explicitly acknowledged by the consumer

      Default value is AcknowledgeMode.MANUAL
      Parameters:
      mode - the acknowledgment mode to use
      Returns:
      arguments object
      See Also:
    • headersCodec

      QueuePollArgs headersCodec(Codec codec)
      Specifies the codec to use for decoding message headers.
      Parameters:
      codec - the codec to use for header deserialization
      Returns:
      arguments object
    • timeout

      QueuePollArgs timeout(Duration value)
      Sets the maximum time to wait for messages to become available.

      If the queue is empty, the poll operation will block until either:

      • At least one message becomes available
      • The specified timeout duration elapses

      If the timeout elapses without any messages becoming available, the poll operation will return empty collection of messages.

      0 means to wait indefinitely for a message.

      Default value is undefined.

      Parameters:
      value - the maximum duration to wait for messages
      Returns:
      arguments object
    • visibility

      QueuePollArgs visibility(Duration value)
      Sets the visibility timeout for retrieved messages.

      The visibility timeout specifies how long a message will be hidden from other consumers after it has been retrieved but before it has been acknowledged or negatively acknowledged. This prevents other consumers from processing the same message while it's being handled.

      If a message is not acknowledged within this time period, it will become visible again in the queue and may be delivered to another consumer.

      If not defined, the queue's visibility setting value is used. If queue's visibility setting is also not set, the default value is 30 seconds.

      Parameters:
      value - the duration for which retrieved messages should remain invisible to other consumers
      Returns:
      arguments object
    • count

      QueuePollArgs count(int value)
      Sets the maximum number of messages to retrieve in a single poll operation.

      This parameter enables batch retrieval of messages, which can improve throughput when processing multiple messages at once. The actual number of messages returned may be less than the requested count if fewer messages are available.

      Parameters:
      value - the maximum number of messages to retrieve
      Returns:
      arguments object