java.lang.Object
dk.cloudcreate.essentials.components.foundation.messaging.queue.operations.ConsumeFromQueue

public class ConsumeFromQueue extends Object
Start an asynchronous message consumer.
Note: There can only be one DurableQueueConsumer per QueueName per DurableQueues instance Operation also matches DurableQueuesInterceptor.intercept(ConsumeFromQueue, InterceptorChain)
  • Field Details

  • Constructor Details

    • ConsumeFromQueue

      public ConsumeFromQueue(String consumerName, QueueName queueName, RedeliveryPolicy redeliveryPolicy, int parallelConsumers, QueuedMessageHandler queueMessageHandler, Duration pollingInterval)
      Start an asynchronous message consumer.
      Note: There can only be one DurableQueueConsumer per QueueName per DurableQueues instance
      Parameters:
      consumerName - the name of the consumer (for logging purposes)
      queueName - the name of the queue that the consumer will be listening for queued messages ready to be delivered to the QueuedMessageHandler provided
      redeliveryPolicy - the redelivery policy in case the handling of a message fails
      parallelConsumers - the number of parallel consumers (if number > 1 then you will effectively have competing consumers on the current node)
      queueMessageHandler - the message handler that will receive QueuedMessage's. See PatternMatchingQueuedMessageHandler
      pollingInterval - the interval with which the consumer poll the queue db for new messages to process
    • ConsumeFromQueue

      public ConsumeFromQueue(String consumerName, QueueName queueName, RedeliveryPolicy redeliveryPolicy, int parallelConsumers, ScheduledExecutorService consumerExecutorService, QueuedMessageHandler queueMessageHandler, Duration pollingInterval)
      Start an asynchronous message consumer.
      Note: There can only be one DurableQueueConsumer per QueueName per DurableQueues instance
      Parameters:
      consumerName - the name of the consumer (for logging purposes)
      queueName - the name of the queue that the consumer will be listening for queued messages ready to be delivered to the QueuedMessageHandler provided
      redeliveryPolicy - the redelivery policy in case the handling of a message fails
      parallelConsumers - the number of parallel consumers (if number > 1 then you will effectively have competing consumers on the current node)
      consumerExecutorService - the optional ScheduledExecutorService that's responsible for scheduling the parallelConsumers. Also see ThreadFactoryBuilder
      queueMessageHandler - the message handler that will receive QueuedMessage's. See PatternMatchingQueuedMessageHandler
      pollingInterval - the interval with which the consumer poll the queue db for new messages to process
    • ConsumeFromQueue

      public ConsumeFromQueue(String consumerName, QueueName queueName, RedeliveryPolicy redeliveryPolicy, int parallelConsumers, Optional<ScheduledExecutorService> consumerExecutorService, QueuedMessageHandler queueMessageHandler, Duration pollingInterval)
      Start an asynchronous message consumer.
      Note: There can only be one DurableQueueConsumer per QueueName per DurableQueues instance
      Parameters:
      consumerName - the name of the consumer (for logging purposes)
      queueName - the name of the queue that the consumer will be listening for queued messages ready to be delivered to the QueuedMessageHandler provided
      redeliveryPolicy - the redelivery policy in case the handling of a message fails
      parallelConsumers - the number of parallel consumers (if number > 1 then you will effectively have competing consumers on the current node)
      consumerExecutorService - the optional ScheduledExecutorService that's responsible for scheduling the parallelConsumers. Also see ThreadFactoryBuilder
      queueMessageHandler - the message handler that will receive QueuedMessage's. See PatternMatchingQueuedMessageHandler
      pollingInterval - the interval with which the consumer poll the queue db for new messages to process
  • Method Details

    • builder

      public static ConsumeFromQueueBuilder builder()
      Create a new builder that produces a new ConsumeFromQueue instance
      Returns:
      a new ConsumeFromQueueBuilder instance
    • getConsumerName

      public String getConsumerName()
      Returns:
      the consumer name (for logging purposes)
    • getPollingInterval

      public Duration getPollingInterval()
      Returns:
      the interval with which the consumer poll the queue db for new messages to process
    • getRedeliveryPolicy

      public RedeliveryPolicy getRedeliveryPolicy()
      Returns:
      the redelivery policy in case the handling of a message fails
    • setRedeliveryPolicy

      public void setRedeliveryPolicy(RedeliveryPolicy redeliveryPolicy)
      Parameters:
      redeliveryPolicy - the redelivery policy in case the handling of a message fails
    • getQueueName

      public QueueName getQueueName()
      Returns:
      the name of the queue that the consumer will be listening for queued messages ready to be delivered to the QueuedMessageHandler provided
    • getParallelConsumers

      public int getParallelConsumers()
      Returns:
      the number of parallel consumers (if number > 1 then you will effectively have competing consumers on the current node)
    • getConsumerExecutorService

      public Optional<ScheduledExecutorService> getConsumerExecutorService()
      Returns:
      the optional ScheduledExecutorService that's responsible for controlling the number of Message consumer instance.
    • getQueueMessageHandler

      public QueuedMessageHandler getQueueMessageHandler()
      Returns:
      the message handler that will receive QueuedMessage's
      See Also:
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • validate

      public void validate()