Interface IdempotentRepository
- All Superinterfaces:
AutoCloseable, Service
Persistent store of message identifiers that implements the
Idempotent Consumer pattern, ensuring each
message is processed at most once.
The
add and contains methods follow the Set contract: add(String) returns
true only when the key is new (first occurrence), and contains(String) tests membership without
adding.
The repository supports two processing modes, controlled by the Idempotent Consumer EIP configuration:
- eager (default) —
add(String)is called on entry. On success,confirm(String)commits the key. On failure,remove(String)rolls back so the message can be redelivered. - non-eager —
contains(String)guards entry;add(String)is only called on success.remove(String)is still called on failure.
-
Method Summary
Modifier and TypeMethodDescriptionbooleanAdds the key to the repository.default booleanAdds the key to the repository.voidclear()Clear the repository.booleanConfirms the key, after the exchange has been processed successfully.default booleanConfirms the key, after the exchange has been processed successfully.booleanReturns true if this repository contains the specified element.default booleanReturns true if this repository contains the specified element.booleanRemoves the key from the repository.default booleanRemoves the key from the repository.
-
Method Details
-
add
Adds the key to the repository. Important: Read the class javadoc about eager vs non-eager mode.- Parameters:
key- the key of the message for duplicate test- Returns:
- true if this repository did not already contain the specified element
-
contains
Returns true if this repository contains the specified element. Important: Read the class javadoc about eager vs non-eager mode.- Parameters:
key- the key of the message- Returns:
- true if this repository contains the specified element
-
remove
Removes the key from the repository. Is usually invoked if the exchange failed. Important: Read the class javadoc about eager vs non-eager mode.- Parameters:
key- the key of the message for duplicate test- Returns:
- true if the key was removed
-
confirm
Confirms the key, after the exchange has been processed successfully. Important: Read the class javadoc about eager vs non-eager mode.- Parameters:
key- the key of the message for duplicate test- Returns:
- true if the key was confirmed
-
clear
void clear()Clear the repository. Important: Read the class javadoc about eager vs non-eager mode. -
add
-
contains
-
remove
-
confirm
-