Search in sources :

Example 1 with Filterable

use of org.apache.qpid.server.filter.Filterable in project qpid-broker-j by apache.

the class DirectExchangeImpl method doRoute.

@Override
public <M extends ServerMessage<? extends StorableMessageMetaData>> void doRoute(final M payload, final String routingKey, final InstanceProperties instanceProperties, final RoutingResult<M> result) {
    BindingSet bindings = _bindingsByKey.get(routingKey == null ? "" : routingKey);
    if (bindings != null) {
        final Map<MessageDestination, String> unfilteredDestinations = bindings.getUnfilteredDestinations();
        for (MessageDestination destination : unfilteredDestinations.keySet()) {
            String actualRoutingKey = unfilteredDestinations.get(destination) == null ? routingKey : unfilteredDestinations.get(destination);
            result.add(destination.route(payload, actualRoutingKey, instanceProperties));
        }
        if (bindings.hasFilteredQueues()) {
            Filterable filterable = Filterable.Factory.newInstance(payload, instanceProperties);
            Map<MessageDestination, FilterManagerReplacementRoutingKeyTuple> filteredDestinations = bindings.getFilteredDestinations();
            for (Map.Entry<MessageDestination, FilterManagerReplacementRoutingKeyTuple> entry : filteredDestinations.entrySet()) {
                FilterManagerReplacementRoutingKeyTuple tuple = entry.getValue();
                String actualRoutingKey = tuple.getReplacementRoutingKey() == null ? routingKey : tuple.getReplacementRoutingKey();
                if (tuple.getFilterManager().allAllow(filterable)) {
                    result.add(entry.getKey().route(payload, actualRoutingKey, instanceProperties));
                }
            }
        }
    }
}
Also used : MessageDestination(org.apache.qpid.server.message.MessageDestination) Filterable(org.apache.qpid.server.filter.Filterable) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) Map(java.util.Map)

Aggregations

HashMap (java.util.HashMap)1 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ConcurrentMap (java.util.concurrent.ConcurrentMap)1 Filterable (org.apache.qpid.server.filter.Filterable)1 MessageDestination (org.apache.qpid.server.message.MessageDestination)1