Class ConsumeFromQueue
java.lang.Object
dk.cloudcreate.essentials.components.foundation.messaging.queue.operations.ConsumeFromQueue
Start an asynchronous message consumer.
Note: There can only be one
Note: There can only be one
DurableQueueConsumer per QueueName per DurableQueues instance
Operation also matches DurableQueuesInterceptor.intercept(ConsumeFromQueue, InterceptorChain)-
Field Summary
FieldsModifier and TypeFieldDescriptionfinal StringThe name of the consumer (for logging purposes)final QueuedMessageHandlerThe message handler that will receiveQueuedMessage'sfinal QueueNameThe name of the queue that the consumer will be listening for queued messages ready to be delivered to theQueuedMessageHandlerprovided -
Constructor Summary
ConstructorsConstructorDescriptionConsumeFromQueue(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
Modifier and TypeMethodDescriptionstatic ConsumeFromQueueBuilderbuilder()Create a new builder that produces a newConsumeFromQueueinstanceintvoidsetRedeliveryPolicy(RedeliveryPolicy redeliveryPolicy) toString()voidvalidate()
-
Field Details
-
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 theQueuedMessageHandlerprovided -
queueMessageHandler
The message handler that will receiveQueuedMessage's- See Also:
-
-
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 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 Details
-
builder
Create a new builder that produces a newConsumeFromQueueinstance- Returns:
- a new
ConsumeFromQueueBuilderinstance
-
getConsumerName
- Returns:
- the consumer name (for logging purposes)
-
getPollingInterval
- Returns:
- the interval with which the consumer poll the queue db for new messages to process
-
getRedeliveryPolicy
- Returns:
- the redelivery policy in case the handling of a message fails
-
setRedeliveryPolicy
- Parameters:
redeliveryPolicy- the redelivery policy in case the handling of a message fails
-
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
- Returns:
- the optional
ScheduledExecutorServicethat's responsible for controlling the number of Message consumer instance.
-
getQueueMessageHandler
- Returns:
- the message handler that will receive
QueuedMessage's - See Also:
-
toString
-
validate
public void validate()
-