Class DefaultQueuedMessage
java.lang.Object
dk.cloudcreate.essentials.components.foundation.messaging.queue.DefaultQueuedMessage
- All Implemented Interfaces:
QueuedMessage
Represents a message queued onto a Durable Queue
-
Nested Class Summary
Nested classes/interfaces inherited from interface dk.cloudcreate.essentials.components.foundation.messaging.queue.QueuedMessage
QueuedMessage.DeliveryMode -
Field Summary
FieldsModifier and TypeFieldDescriptionfinal OffsetDateTimefinal OffsetDateTimefinal QueueEntryIdfinal booleanfinal booleanfinal Stringfinal MessageThe deserialized message payloadfinal OffsetDateTimefinal QueueNamefinal intfinal int -
Constructor Summary
ConstructorsConstructorDescriptionDefaultQueuedMessage(QueueEntryId id, QueueName queueName, Message message, OffsetDateTime addedTimestamp, OffsetDateTime nextDeliveryTimestamp, OffsetDateTime deliveryTimestamp, String lastDeliveryError, int totalDeliveryAttempts, int redeliveryAttempts, boolean isDeadLetterMessage, boolean isBeingDelivered) -
Method Summary
Modifier and TypeMethodDescriptionbooleanWhen was this message first enqueued (or directly added as a Dead-letter-message)Get the message'sQueuedMessage.DeliveryModeIfQueuedMessage.isBeingDelivered()is true, thenQueuedMessage.getDeliveryTimestamp()returns the timestamp for when the message delivery started.getId()The unique queue entry id for this messageGet the error from the last delivery (null if no error is recorded)Get the message queuedTimestamp for when the message should be delivered next time.Name of the Queue that the message is enqueued onintHow many times has we attempted to re-deliver this message (same asQueuedMessage.getTotalDeliveryAttempts()-1)In caseQueuedMessage.isManuallyMarkedForRedelivery()returns true, then this method will return the requested redelivery delayintGet the total number of delivery attempts for this messageinthashCode()booleanIs the message currently being delivered to a message consumerbooleanIs this a poison/dead-letter message that will not be delivered untilDurableQueues.resurrectDeadLetterMessage(ResurrectDeadLetterMessage)is calledbooleanIs the message marked for redelivery - i.e.voidmarkForRedeliveryIn(Duration deliveryDelay) Mark the message for redelivery with the specified deliveryDelay - this manually requested redelivery counts towards the specifiedRedeliveryPolicy.maximumNumberOfRedeliveries
AQueuedMessageHandlercan choose to call this method directly to have the message be redelivered.
Note: AQueuedMessageHandlershould never directly callDurableQueues.retryMessage(RetryMessage)as this doesn't set theQueuedMessage.isManuallyMarkedForRedelivery()flag which theDefaultDurableQueueConsumerrelies upon for manually requested message redeliveriestoString()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface dk.cloudcreate.essentials.components.foundation.messaging.queue.QueuedMessage
getMetaData, getPayload
-
Field Details
-
id
-
queueName
-
message
The deserialized message payload -
addedTimestamp
-
nextDeliveryTimestamp
-
deliveryTimestamp
-
lastDeliveryError
-
totalDeliveryAttempts
public final int totalDeliveryAttempts -
redeliveryAttempts
public final int redeliveryAttempts -
isDeadLetterMessage
public final boolean isDeadLetterMessage -
isBeingDelivered
public final boolean isBeingDelivered
-
-
Constructor Details
-
DefaultQueuedMessage
public DefaultQueuedMessage(QueueEntryId id, QueueName queueName, Message message, OffsetDateTime addedTimestamp, OffsetDateTime nextDeliveryTimestamp, OffsetDateTime deliveryTimestamp, String lastDeliveryError, int totalDeliveryAttempts, int redeliveryAttempts, boolean isDeadLetterMessage, boolean isBeingDelivered)
-
-
Method Details
-
getId
Description copied from interface:QueuedMessageThe unique queue entry id for this message- Specified by:
getIdin interfaceQueuedMessage- Returns:
-
getQueueName
Description copied from interface:QueuedMessageName of the Queue that the message is enqueued on- Specified by:
getQueueNamein interfaceQueuedMessage- Returns:
- name of the Queue that the message is enqueued on
-
getMessage
Description copied from interface:QueuedMessageGet the message queued- Specified by:
getMessagein interfaceQueuedMessage
-
getDeliveryMode
Description copied from interface:QueuedMessageGet the message'sQueuedMessage.DeliveryMode- Specified by:
getDeliveryModein interfaceQueuedMessage- Returns:
- the message's
QueuedMessage.DeliveryMode
-
isBeingDelivered
public boolean isBeingDelivered()Description copied from interface:QueuedMessageIs the message currently being delivered to a message consumer- Specified by:
isBeingDeliveredin interfaceQueuedMessage- Returns:
- s the message currently being delivered to a message consumer
-
getAddedTimestamp
Description copied from interface:QueuedMessageWhen was this message first enqueued (or directly added as a Dead-letter-message)- Specified by:
getAddedTimestampin interfaceQueuedMessage- Returns:
- when was this message first enqueued
-
getNextDeliveryTimestamp
Description copied from interface:QueuedMessageTimestamp for when the message should be delivered next time. Null ifQueuedMessage.isDeadLetterMessage()is true- Specified by:
getNextDeliveryTimestampin interfaceQueuedMessage- Returns:
- timestamp for when the message should be delivered next time. Null if
QueuedMessage.isDeadLetterMessage()is true
-
getDeliveryTimestamp
Description copied from interface:QueuedMessageIfQueuedMessage.isBeingDelivered()is true, thenQueuedMessage.getDeliveryTimestamp()returns the timestamp for when the message delivery started. Otherwise, this property is null.- Specified by:
getDeliveryTimestampin interfaceQueuedMessage- Returns:
- the timestamp for when the message delivery started
-
markForRedeliveryIn
Description copied from interface:QueuedMessageMark the message for redelivery with the specified deliveryDelay - this manually requested redelivery counts towards the specifiedRedeliveryPolicy.maximumNumberOfRedeliveries
AQueuedMessageHandlercan choose to call this method directly to have the message be redelivered.
Note: AQueuedMessageHandlershould never directly callDurableQueues.retryMessage(RetryMessage)as this doesn't set theQueuedMessage.isManuallyMarkedForRedelivery()flag which theDefaultDurableQueueConsumerrelies upon for manually requested message redeliveries- Specified by:
markForRedeliveryInin interfaceQueuedMessage- Parameters:
deliveryDelay- how long will the queue wait until it delivers the message to theDurableQueueConsumer
-
isManuallyMarkedForRedelivery
public boolean isManuallyMarkedForRedelivery()Description copied from interface:QueuedMessageIs the message marked for redelivery - i.e.QueuedMessage.markForRedeliveryIn(Duration)has been called on the message- Specified by:
isManuallyMarkedForRedeliveryin interfaceQueuedMessage- Returns:
- Is the message marked for redelivery
-
getRedeliveryDelay
Description copied from interface:QueuedMessageIn caseQueuedMessage.isManuallyMarkedForRedelivery()returns true, then this method will return the requested redelivery delay- Specified by:
getRedeliveryDelayin interfaceQueuedMessage- Returns:
- how long will the queue wait until it delivers the message to the
DurableQueueConsumer
-
getLastDeliveryError
Description copied from interface:QueuedMessageGet the error from the last delivery (null if no error is recorded)- Specified by:
getLastDeliveryErrorin interfaceQueuedMessage- Returns:
- Get the error from the last delivery (null if no error is recorded)
-
getTotalDeliveryAttempts
public int getTotalDeliveryAttempts()Description copied from interface:QueuedMessageGet the total number of delivery attempts for this message- Specified by:
getTotalDeliveryAttemptsin interfaceQueuedMessage- Returns:
- the total number of delivery attempts for this message
-
getRedeliveryAttempts
public int getRedeliveryAttempts()Description copied from interface:QueuedMessageHow many times has we attempted to re-deliver this message (same asQueuedMessage.getTotalDeliveryAttempts()-1)- Specified by:
getRedeliveryAttemptsin interfaceQueuedMessage- Returns:
- how many times has we attempted to re-deliver this message (same as
QueuedMessage.getTotalDeliveryAttempts()-1)
-
isDeadLetterMessage
public boolean isDeadLetterMessage()Description copied from interface:QueuedMessageIs this a poison/dead-letter message that will not be delivered untilDurableQueues.resurrectDeadLetterMessage(ResurrectDeadLetterMessage)is called- Specified by:
isDeadLetterMessagein interfaceQueuedMessage- Returns:
- Is this a poison/dead-letter message
-
equals
-
hashCode
public int hashCode() -
toString
-