Enum TransactionalMode
- java.lang.Object
-
- java.lang.Enum<TransactionalMode>
-
- dk.cloudcreate.essentials.components.foundation.messaging.queue.TransactionalMode
-
- All Implemented Interfaces:
Serializable,Comparable<TransactionalMode>
public enum TransactionalMode extends Enum<TransactionalMode>
The transactional behaviour mode of aDurableQueues
-
-
Enum Constant Summary
Enum Constants Enum Constant Description FullyTransactionalWhen using this mode all the queueing, de-queueing methods requires an existingUnitOfWorkstarted prior to being called.ManualAcknowledgementCertain NoSQL databases, such as MongoDB/DocumentDB, has limitations when performing multiple data storage operations within a transaction.
For these cases you can configure theTransactionalModeasManualAcknowledgementwhere queueing and de-queueing are performed using separate (single document) transactions and where acknowledging/retry are performed as separate transactions.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static TransactionalModevalueOf(String name)Returns the enum constant of this type with the specified name.static TransactionalMode[]values()Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
FullyTransactional
public static final TransactionalMode FullyTransactional
When using this mode all the queueing, de-queueing methods requires an existingUnitOfWorkstarted prior to being called. The reason for this is that Queues are typically used together with theInboxOutboxpattern, which benefits from including queueing/de-queueing together with other database entity modifying operations.
When changing an entity and queueing/de-queueing happens in ONE shared transaction (NOTE this requires that the entity storage and the queue storage to use the same database - e.g. Postgresql or MongoDB) then the shared database transaction guarantees that all the data storage operations are committed or rollback as one
-
ManualAcknowledgement
public static final TransactionalMode ManualAcknowledgement
Certain NoSQL databases, such as MongoDB/DocumentDB, has limitations when performing multiple data storage operations within a transaction.
For these cases you can configure theTransactionalModeasManualAcknowledgementwhere queueing and de-queueing are performed using separate (single document) transactions and where acknowledging/retry are performed as separate transactions. Depending on the type of errors that can occur this MAY leave a dequeued message in a state of being marked as "being delivered" forever. HenceDurableQueuessupporting this mode must ensure that they periodically discover messages that have been under delivery for a long time (aka. stuck messages or timed-out messages) and reset them in order for them to be redelivered.
Example:durableQueues.queueMessage(queueName, message); var msgUnderDelivery = durableQueues.getNextMessageReadyForDelivery(queueName); if (msgUnderDelivery.isPresent()) { try { handleMessage(msgUnderDelivery.get()); durableQueues.acknowledgeMessageAsHandled(msgUnderDelivery.get().getId()); } catch (Exception e) { durableQueues.retryMessage(msgUnderDelivery.get().getId(), e, Duration.ofMillis(500)); } }
-
-
Method Detail
-
values
public static TransactionalMode[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (TransactionalMode c : TransactionalMode.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static TransactionalMode valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum type has no constant with the specified nameNullPointerException- if the argument is null
-
-