Class ConsumeFromQueue
- 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 oneDurableQueueConsumerperQueueNameperDurableQueuesinstance Operation also matchesDurableQueuesInterceptor.intercept(ConsumeFromQueue, InterceptorChain)
-
-
Field Summary
Fields Modifier and Type Field Description StringconsumerNameThe name of the consumer (for logging purposes)QueuedMessageHandlerqueueMessageHandlerThe message handler that will receiveQueuedMessage'sQueueNamequeueNameThe name of the queue that the consumer will be listening for queued messages ready to be delivered to theQueuedMessageHandlerprovided
-
Constructor Summary
Constructors Constructor Description ConsumeFromQueue(String consumerName, QueueName queueName, RedeliveryPolicy redeliveryPolicy, int parallelConsumers, QueuedMessageHandler queueMessageHandler, Duration pollingInterval)Start an asynchronous message consumer.
Note: There can only be oneDurableQueueConsumerperQueueNameperDurableQueuesinstanceConsumeFromQueue(String consumerName, QueueName queueName, RedeliveryPolicy redeliveryPolicy, int parallelConsumers, ScheduledExecutorService consumerExecutorService, QueuedMessageHandler queueMessageHandler, Duration pollingInterval)Start an asynchronous message consumer.
Note: There can only be oneDurableQueueConsumerperQueueNameperDurableQueuesinstanceConsumeFromQueue(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 oneDurableQueueConsumerperQueueNameperDurableQueuesinstance
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ConsumeFromQueueBuilderbuilder()Create a new builder that produces a newConsumeFromQueueinstanceOptional<ScheduledExecutorService>getConsumerExecutorService()StringgetConsumerName()intgetParallelConsumers()DurationgetPollingInterval()QueuedMessageHandlergetQueueMessageHandler()QueueNamegetQueueName()RedeliveryPolicygetRedeliveryPolicy()voidsetRedeliveryPolicy(RedeliveryPolicy redeliveryPolicy)StringtoString()voidvalidate()
-
-
-
Field Detail
-
consumerName
public final String consumerName
The name of the consumer (for logging purposes)
-
queueName
public final QueueName queueName
The name of the queue that the consumer will be listening for queued messages ready to be delivered to theQueuedMessageHandlerprovided
-
queueMessageHandler
public final QueuedMessageHandler queueMessageHandler
The message handler that will receiveQueuedMessage's- See Also:
PatternMatchingQueuedMessageHandler
-
-
Constructor Detail
-
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 oneDurableQueueConsumerperQueueNameperDurableQueuesinstance- 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 theQueuedMessageHandlerprovidedredeliveryPolicy- the redelivery policy in case the handling of a message failsparallelConsumers- 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 receiveQueuedMessage's. SeePatternMatchingQueuedMessageHandlerpollingInterval- 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 oneDurableQueueConsumerperQueueNameperDurableQueuesinstance- 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 theQueuedMessageHandlerprovidedredeliveryPolicy- the redelivery policy in case the handling of a message failsparallelConsumers- the number of parallel consumers (if number > 1 then you will effectively have competing consumers on the current node)consumerExecutorService- the optionalScheduledExecutorServicethat's responsible for scheduling theparallelConsumers. Also seeThreadFactoryBuilderqueueMessageHandler- the message handler that will receiveQueuedMessage's. SeePatternMatchingQueuedMessageHandlerpollingInterval- 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 oneDurableQueueConsumerperQueueNameperDurableQueuesinstance- 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 theQueuedMessageHandlerprovidedredeliveryPolicy- the redelivery policy in case the handling of a message failsparallelConsumers- the number of parallel consumers (if number > 1 then you will effectively have competing consumers on the current node)consumerExecutorService- the optionalScheduledExecutorServicethat's responsible for scheduling theparallelConsumers. Also seeThreadFactoryBuilderqueueMessageHandler- the message handler that will receiveQueuedMessage's. SeePatternMatchingQueuedMessageHandlerpollingInterval- the interval with which the consumer poll the queue db for new messages to process
-
-
Method Detail
-
builder
public static ConsumeFromQueueBuilder builder()
Create a new builder that produces a newConsumeFromQueueinstance- Returns:
- a new
ConsumeFromQueueBuilderinstance
-
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
QueuedMessageHandlerprovided
-
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
ScheduledExecutorServicethat'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:
PatternMatchingQueuedMessageHandler
-
validate
public void validate()
-
-