public interface ConflationConfig extends Config
Conflation is the act of optionally updating a message that is already queued for delivery to a Client with a newer message that is being queued for a Client on the same Topic. Conflation may mean replacing the currently queued message with the new message or may mean merging the content of the two messages to produce a new message which will replace the current message in the queue. The new message may replace the current message positionally within the Client queue or the current message may be removed from the queue and the new message added to the end of the queue.
Conflation may be configured as on for all Clients connecting via a particular connector or it may be turned on programmatically for a specific Client.
A Conflation Policy
defines the conflation
mechanism to be used for one or more Topics when conflation is turned on for
a Client. Only messages for Topics that have a Conflation Policy specified
will be conflated. Messages for Topics that have no Conflation Policy
specified will simply be added to the end of the Client queue even if
conflation is turned on for the Client.
Not all messages are considered for conflation. There are the following
exceptions:
1) Only messages that are queued at MessagePriority#NORMAL normal
priority are considered for conflation. High and low priority messages are
never conflated.
2) Only delta messages are considered for conflation - Topic load messages
are never considered for conflation.
3) Messages that require acknowledgement are not considered for conflation.
Conflation Policies and their mappings may be changed at any time, either before the Server is started or from within Publishers at runtime.
Conflation properties only apply to a Diffusion Server as there is no client side conflation of messages.
Modifier and Type | Method and Description |
---|---|
ConflationPolicyConfig |
addPolicy(String name,
ConflationPolicyConfig.Mode mode)
Add a Conflation Policy which uses the
default Message Matcher and no Message Merger. |
ConflationPolicyConfig |
addPolicy(String name,
ConflationPolicyConfig.Mode mode,
MessageMatcher matcher,
MessageMerger merger)
Adds a conflation policy.
|
ConflationPolicyConfig |
addPolicy(String name,
ConflationPolicyConfig.Mode mode,
MessageMerger merger)
Add a Conflation Policy which uses the
default Message Matcher and a specified Message Merger. |
ConflationPolicyConfig |
addPolicy(String name,
ConflationPolicyConfig.Mode mode,
String matcherClass,
String mergerClass)
Adds a conflation policy
|
ConflationPolicyConfig |
getDefaultPolicy()
Gets the the default conflation policy.
|
List<ConflationPolicyConfig> |
getPolicies()
Get the list of configured conflation policies.
|
ConflationPolicyConfig |
getPolicy(String name)
Get a named conflation policy.
|
ConflationPolicyConfig |
getPolicyForTopic(String topicName)
Get the Conflation Policy that will be used for a specified Topic.
|
List<TopicConflationPolicyConfig> |
getTopicPolicies()
Get a list of all Topic to Conflation Policy conflation mappings.
|
TopicConflationPolicyConfig |
getTopicPolicy(String topicSelector)
Get the Topic Conflation Policy for a given topic pattern.
|
void |
removeAllPolicies()
Remove all conflation policies and mappings.
|
ConflationPolicyConfig |
removePolicy(String name)
Remove a named conflation policy and all mappings to it.
|
void |
setDefaultPolicy(String policyName)
Sets the default conflation policy.
|
TopicConflationPolicyConfig |
setTopicPolicy(String topic,
String policy)
Set a new Topic to Conflation Policy mapping.
|
TopicConflationPolicyConfig |
unsetTopicPolicy(String topicPattern)
Remove the Topic to Conflation Policy mapping for a specified Topic
selector pattern.
|
void setDefaultPolicy(String policyName) throws ConfigException
If a default conflation policy is set and conflation is enabled, then messages for any Topic that does not have a specific conflation policy would use the default policy.
If no default conflation policy is set (the default) then messages for any topic that does not have a conflation policy specified will not be conflated.
It is strongly advised that conflation policies be applied explicitly to
topics or topic selectors with setTopicPolicy(java.lang.String, java.lang.String)
,
rather than in this global manner to avoid potential side effects.
policyName
- the name of the default conflation policy.ConfigException
- if unable to set the propertyConflationPolicyConfig getDefaultPolicy()
List<ConflationPolicyConfig> getPolicies()
ConflationPolicyConfig getPolicy(String name)
name
- the conflation policy nameConflationPolicyConfig addPolicy(String name, ConflationPolicyConfig.Mode mode) throws ConfigException
default
Message Matcher and no Message Merger.name
- the policy namemode
- the policy mode. If not supplied then ConflationPolicyConfig.Mode.REPLACE
is
assumed.ConfigException
- if unable to create the policy, possibly because
a policy with the given name already exists.ConflationPolicyConfig addPolicy(String name, ConflationPolicyConfig.Mode mode, MessageMerger merger) throws ConfigException
default
Message Matcher and a specified Message Merger.name
- the policy namemode
- the policy mode. If not supplied then ConflationPolicyConfig.Mode.REPLACE
is
assumed.merger
- the message merger. If not supplied then no message merger
is used.ConfigException
- if unable to create new policy, possibly because
one already exists with the same name.ConflationPolicyConfig addPolicy(String name, ConflationPolicyConfig.Mode mode, String matcherClass, String mergerClass) throws ConfigException
This allows MessageMatcher
and MessageMerger
classes to
be specified by class name. If there is already an instance of the
specified class then it will be used otherwise a new instance will be
created and cached. Using this technique the same instances could be used
by many different Conflation Policies.
name
- the policy namemode
- the policy mode. If not supplied then ConflationPolicyConfig.Mode.REPLACE
is
assumed.matcherClass
- the full class name of a class of type
MessageMatcher
which indicates the matcher to use. If this
is specified as null then MessageMatcher.DEFAULT
is
assumed.mergerClass
- the full class name of a class of type
MessageMerger
which indicates the merger to use. If this
is specified as null then no merger will be used.ConfigException
- if unable to create new policyConflationPolicyConfig addPolicy(String name, ConflationPolicyConfig.Mode mode, MessageMatcher matcher, MessageMerger merger) throws ConfigException
name
- the policy namemode
- the policy mode. If not supplied then ConflationPolicyConfig.Mode.REPLACE
is
assumed.matcher
- the message matcher to use or null to use
MessageMatcher.DEFAULT
.merger
- the message merger to use or null to indicate that merging
is not to take placeConfigException
- if unable to create the policyConflationPolicyConfig removePolicy(String name)
name
- the policy namevoid removeAllPolicies()
List<TopicConflationPolicyConfig> getTopicPolicies()
TopicConflationPolicyConfig setTopicPolicy(String topic, String policy) throws ConfigException
Note that the order that these are set is significant with the last always taking precedence. This means that if there are two mappings that would map for the same topic then the last would always be the one that is used.
If a mapping is set for a selector pattern that is already mapped then the old mapping will be removed and the new one added to the end of the list of mappings.
topic
- the topic name or topic selector patternpolicy
- the name of a configured conflation policyConfigException
- if unable to add a mappingTopicConflationPolicyConfig getTopicPolicy(String topicSelector)
The supplied pattern would have to be an exact match for a pattern
previously supplied to setTopicPolicy(String, String)
.
topicSelector
- the topic selector pattern to return the mapping
for.ConflationPolicyConfig getPolicyForTopic(String topicName)
This will search through all defined mappings (latest first) and return the first that matches with the given topic name. If there is no match then the default policy will be returned.
topicName
- a topic nameTopicConflationPolicyConfig unsetTopicPolicy(String topicPattern)
The supplied pattern would have to be exactly as supplied to a previous
call of setTopicPolicy(String, String)
.
topicPattern
- the Topic pattern.Copyright © 2016 Push Technology Ltd. All Rights Reserved.