Interface MessageLockService
-
- All Known Implementing Classes:
DefaultMessageLockService
public interface MessageLockService
Service that is responsible for managing locks for the processing of aMessage
. These locks are leveraged by theIdempotentMessageConsumptionService
to ensure that a message is only processed once per listener.- Author:
- Chris Kittrell (ckittrell)
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description String
obtainLock(org.springframework.messaging.Message<?> message, String listenerName)
void
purgeLocks(Duration messageLockTtl)
Deletes all message locks that are out of date according to themessageLockTtl
.void
releaseLock(String lockToken)
Releases the lock so that the relevant message can be processed again.
-
-
-
Method Detail
-
obtainLock
String obtainLock(org.springframework.messaging.Message<?> message, String listenerName)
- Parameters:
message
- The message that is to be lockedlistenerName
- The name of the message listener. This value can be used to distinguish this message consumption from that of a different message listener.- Returns:
- A unique token that can later be used to release the lock
-
releaseLock
void releaseLock(@Nullable String lockToken)
Releases the lock so that the relevant message can be processed again. We primarily want to use this method when an unexpected error is encountered while processing the message.- Parameters:
lockToken
- The unique token that was provided when the lock was obtained
-
purgeLocks
void purgeLocks(Duration messageLockTtl)
Deletes all message locks that are out of date according to themessageLockTtl
.- Parameters:
messageLockTtl
- How long the lock should be held. If the lock is too old, then it should be removed.
-
-