Class MetadataStoreSelector
- All Implemented Interfaces:
- GenericSelector<Message<?>>,- MessageSelector
MessageSelector implementation using a ConcurrentMetadataStore
 and MessageProcessor.
 
 The accept(org.springframework.messaging.Message<?>) method extracts metadataKey from the provided message
 using MessageProcessor and uses the timestamp header as the value
 (hex) by default. The valueStrategy can be provided to override the default behaviour.
 
 The successful result of the accept(org.springframework.messaging.Message<?>) method is based on the
 ConcurrentMetadataStore.putIfAbsent(java.lang.String, java.lang.String) return value. true is returned
 if putIfAbsent returns null.
 And, at the same time, it means that the value has been placed in the MetadataStore.
 Otherwise the messages isn't accepted because there is already a value in the
 MetadataStore associated with the key.
 
 This MessageSelector is useful for an
 Idempotent Receiver
 implementation.
 
 It can be used in a MessageFilter
 or IdempotentReceiverInterceptor.
- Since:
- 4.1
- Author:
- Artem Bilan, Gary Russell, Christian Tzolov
- 
Constructor SummaryConstructorsConstructorDescriptionMetadataStoreSelector(MessageProcessor<String> keyStrategy) MetadataStoreSelector(MessageProcessor<String> keyStrategy, MessageProcessor<String> valueStrategy) MetadataStoreSelector(MessageProcessor<String> keyStrategy, MessageProcessor<String> valueStrategy, ConcurrentMetadataStore metadataStore) MetadataStoreSelector(MessageProcessor<String> keyStrategy, ConcurrentMetadataStore metadataStore) 
- 
Method SummaryModifier and TypeMethodDescriptionbooleancompareValues(BiPredicate<String, String> compareValues) Fluent version ofsetCompareValues(BiPredicate).voidsetCompareValues(BiPredicate<String, String> compareValues) Set aBiPredicateto compare old and new values in the metadata store for the key.
- 
Constructor Details- 
MetadataStoreSelector
- 
MetadataStoreSelectorpublic MetadataStoreSelector(MessageProcessor<String> keyStrategy, MessageProcessor<String> valueStrategy) 
- 
MetadataStoreSelectorpublic MetadataStoreSelector(MessageProcessor<String> keyStrategy, ConcurrentMetadataStore metadataStore) 
- 
MetadataStoreSelectorpublic MetadataStoreSelector(MessageProcessor<String> keyStrategy, MessageProcessor<String> valueStrategy, ConcurrentMetadataStore metadataStore) 
 
- 
- 
Method Details- 
setCompareValuesSet aBiPredicateto compare old and new values in the metadata store for the key. The first parameter is the old value; return true if we should accept this message and replace the old value with the new value.- Parameters:
- compareValues- the- BiPredicate.
- Since:
- 5.3
 
- 
compareValuesFluent version ofsetCompareValues(BiPredicate).- Parameters:
- compareValues- the- BiPredicate.
- Returns:
- this.
 
- 
accept- Specified by:
- acceptin interface- GenericSelector<Message<?>>
- Specified by:
- acceptin interface- MessageSelector
 
 
-