Class NotificationFilterChain
java.lang.Object
dk.cloudcreate.essentials.components.foundation.postgresql.NotificationFilterChain
Manages a chain of
The key extracted from
If an empty
If two or more
NotificationDuplicationFilter instances and uses them
to extract unique keys from the Notification.getParameter() JSON content.The key extracted from
NotificationDuplicationFilter.extractDuplicationKey(JsonNode)
will be used inside MultiTableChangeListener for duplication checks across all Notification's returned in one poll.If an empty
Optional is returned then the given notification won't be deduplicated.If two or more
Notification's in a given poll batch share the same duplication key, then only one of them will be published to the listeners registered with the MultiTableChangeListener-
Constructor Summary
ConstructorsConstructorDescriptionNotificationFilterChain(com.fasterxml.jackson.databind.ObjectMapper objectMapper) -
Method Summary
Modifier and TypeMethodDescriptionbooleanAdds a customNotificationDuplicationFilterto the filter chain as the very first (highest priority).
Note: Only a single instance of a particularNotificationDuplicationFilter, determined by callingObject.equals(Object)on the filters, can be addedbooleanAdds a customNotificationDuplicationFilterto the filter chain as the very last (lowest priority).
Note: Only a single instance of a particularNotificationDuplicationFilter, determined by callingObject.equals(Object)on the filters, can be addedextractDuplicationKey(String parameterJson) Extracts the duplication key from the given JSON parameter string using the registeredNotificationDuplicationFilter's in sequence.booleanAre there anyNotificationDuplicationFilteradded to the chain?voidRemoves a customNotificationDuplicationFilterfrom the filter chain.
-
Constructor Details
-
NotificationFilterChain
public NotificationFilterChain(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
-
-
Method Details
-
addFilterAsFirst
Adds a customNotificationDuplicationFilterto the filter chain as the very first (highest priority).
Note: Only a single instance of a particularNotificationDuplicationFilter, determined by callingObject.equals(Object)on the filters, can be added- Parameters:
filter- the filter to be added to the chain- Returns:
- true if the filter was added as the first, otherwise false (e.g. the filter was already added)
-
addFilterAsLast
Adds a customNotificationDuplicationFilterto the filter chain as the very last (lowest priority).
Note: Only a single instance of a particularNotificationDuplicationFilter, determined by callingObject.equals(Object)on the filters, can be added- Parameters:
filter- the filter to be added to the chain- Returns:
- true if the filter was added as the last, otherwise false (e.g. the filter was already added)
-
removeFilter
Removes a customNotificationDuplicationFilterfrom the filter chain.- Parameters:
filter- the filter to be added to the chain
-
extractDuplicationKey
Extracts the duplication key from the given JSON parameter string using the registeredNotificationDuplicationFilter's in sequence. The firstNotificationDuplicationFilterto return a non-emptyOptionaldetermines the key.
If an emptyOptionalis returned then the given notification won't be deduplicated.- Parameters:
parameterJson- the JSON string representation of theNotification.getParameter()JSON content.- Returns:
- an
Optionalcontaining the unique key if extraction was successful, otherwise an emptyOptional. - Throws:
IllegalArgumentException- if the JSON is invalid or no unique key can be extracted
-
hasDuplicationFilters
public boolean hasDuplicationFilters()Are there anyNotificationDuplicationFilteradded to the chain?- Returns:
- if there are any
NotificationDuplicationFilteradded to the chain?
-