use of org.apache.qpid.server.exchange.topic.TopicMatcherResult in project qpid-broker-j by apache.
the class TopicExchangeImpl method getMatchedDestinations.
private Map<MessageDestination, Set<String>> getMatchedDestinations(Filterable message, String routingKey) {
Collection<TopicMatcherResult> results = _parser.parse(routingKey);
if (!results.isEmpty()) {
Map<MessageDestination, Set<String>> matchedDestinations = new HashMap<>();
for (TopicMatcherResult result : results) {
TopicExchangeResult topicExchangeResult = (TopicExchangeResult) result;
Map<MessageDestination, String> destinations = topicExchangeResult.processMessage(message);
if (!destinations.isEmpty()) {
destinations.forEach((destination, replacementKey) -> {
Set<String> currentKeys = matchedDestinations.get(destination);
if (currentKeys == null) {
matchedDestinations.put(destination, Collections.singleton(replacementKey));
} else if (!currentKeys.contains(replacementKey)) {
Set<String> newKeys = new HashSet<>(currentKeys);
newKeys.add(replacementKey);
matchedDestinations.put(destination, newKeys);
}
});
}
}
return matchedDestinations;
}
return Collections.emptyMap();
}
Aggregations