Class DefaultDurableQueueConsumer<DURABLE_QUEUES extends DurableQueues,UOW extends UnitOfWork,UOW_FACTORY extends UnitOfWorkFactory<UOW>>
- java.lang.Object
-
- dk.cloudcreate.essentials.components.foundation.messaging.queue.DefaultDurableQueueConsumer<DURABLE_QUEUES,UOW,UOW_FACTORY>
-
- Type Parameters:
DURABLE_QUEUES- the concrete type ofDurableQueuesimplementationUOW- theUnitOfWorktypeUOW_FACTORY- theUnitOfWorkFactorytype
- All Implemented Interfaces:
Lifecycle,DurableQueueConsumer,DurableQueueConsumerNotifications
public class DefaultDurableQueueConsumer<DURABLE_QUEUES extends DurableQueues,UOW extends UnitOfWork,UOW_FACTORY extends UnitOfWorkFactory<UOW>> extends Object implements DurableQueueConsumer, DurableQueueConsumerNotifications
The defaultDurableQueueConsumerwhich provides basic implementation (including retrying messages in case of failure, polling interval optimization, etc.)
-
-
Field Summary
Fields Modifier and Type Field Description static RunnableNO_POSTPROCESSING_AFTER_PROCESS_NEXT_MESSAGEQueueNamequeueName
-
Constructor Summary
Constructors Constructor Description DefaultDurableQueueConsumer(ConsumeFromQueue consumeFromQueue, UOW_FACTORY unitOfWorkFactory, DURABLE_QUEUES durableQueues, Consumer<DurableQueueConsumer> removeDurableQueueConsumer, long pollingIntervalMs, QueuePollingOptimizer queuePollingOptimizer)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcancel()booleanisStarted()Returns true if the process is startedvoidmessageAdded(QueuedMessage queuedMessage)Notification from theDurableQueuesimplementation that a new message has been added to the Queue that the givenDurableQueueConsumeris consuming messages from
Note: A consumer still needs to useDurableQueues.getNextMessageReadyForDelivery(GetNextMessageReadyForDelivery)to ensure proper message locking of messages that they are processingQueueNamequeueName()voidstart()Start the processing.voidstop()Stop the processing.StringtoString()
-
-
-
Constructor Detail
-
DefaultDurableQueueConsumer
public DefaultDurableQueueConsumer(ConsumeFromQueue consumeFromQueue, UOW_FACTORY unitOfWorkFactory, DURABLE_QUEUES durableQueues, Consumer<DurableQueueConsumer> removeDurableQueueConsumer, long pollingIntervalMs, QueuePollingOptimizer queuePollingOptimizer)
-
-
Method Detail
-
start
public void start()
Description copied from interface:LifecycleStart the processing. This operation must be idempotent, such that duplicate calls toLifecycle.start()for an already started process (whereLifecycle.isStarted()returns true) is ignored
-
stop
public void stop()
Description copied from interface:LifecycleStop the processing. This operation must be idempotent, such that duplicate calls toLifecycle.stop()for an already stopped process (whereLifecycle.isStarted()returns false) is ignored
-
isStarted
public boolean isStarted()
Description copied from interface:LifecycleReturns true if the process is started
-
queueName
public QueueName queueName()
- Specified by:
queueNamein interfaceDurableQueueConsumer
-
cancel
public void cancel()
- Specified by:
cancelin interfaceDurableQueueConsumer
-
messageAdded
public void messageAdded(QueuedMessage queuedMessage)
Description copied from interface:DurableQueueConsumerNotificationsNotification from theDurableQueuesimplementation that a new message has been added to the Queue that the givenDurableQueueConsumeris consuming messages from
Note: A consumer still needs to useDurableQueues.getNextMessageReadyForDelivery(GetNextMessageReadyForDelivery)to ensure proper message locking of messages that they are processing- Specified by:
messageAddedin interfaceDurableQueueConsumerNotifications- Parameters:
queuedMessage- the message added
-
-