Search in sources :

Example 36 with MessageDestination

use of org.apache.qpid.server.message.MessageDestination in project qpid-broker-j by apache.

the class TopicExchangeImpl method onBindingUpdated.

@Override
protected synchronized void onBindingUpdated(final BindingIdentifier binding, final Map<String, Object> newArguments) {
    final String bindingKey = binding.getBindingKey();
    final MessageDestination destination = binding.getDestination();
    LOGGER.debug("Updating binding of queue {} with routing key {}", destination.getName(), bindingKey);
    String routingKey = TopicNormalizer.normalize(bindingKey);
    try {
        if (_bindings.containsKey(binding)) {
            TopicExchangeResult result = _topicExchangeResults.get(routingKey);
            updateTopicExchangeResult(result, binding, newArguments);
        }
    } catch (AMQInvalidArgumentException e) {
        throw new ConnectionScopedRuntimeException(e);
    }
}
Also used : MessageDestination(org.apache.qpid.server.message.MessageDestination) AMQInvalidArgumentException(org.apache.qpid.server.filter.AMQInvalidArgumentException) ConnectionScopedRuntimeException(org.apache.qpid.server.util.ConnectionScopedRuntimeException) TopicExchangeResult(org.apache.qpid.server.exchange.topic.TopicExchangeResult)

Example 37 with MessageDestination

use of org.apache.qpid.server.message.MessageDestination in project qpid-broker-j by apache.

the class TopicExchangeImpl method updateTopicExchangeResult.

private void updateTopicExchangeResult(final TopicExchangeResult result, final BindingIdentifier binding, final Map<String, Object> newArguments) throws AMQInvalidArgumentException {
    Map<String, Object> oldArgs = _bindings.put(binding, newArguments);
    MessageDestination destination = binding.getDestination();
    if (FilterSupport.argumentsContainFilter(newArguments)) {
        if (FilterSupport.argumentsContainFilter(oldArgs)) {
            result.replaceDestinationFilter(destination, FilterSupport.createMessageFilter(oldArgs, destination), FilterSupport.createMessageFilter(newArguments, destination));
        } else {
            result.addFilteredDestination(destination, FilterSupport.createMessageFilter(newArguments, destination));
            result.removeUnfilteredDestination(destination);
        }
    } else if (FilterSupport.argumentsContainFilter(oldArgs)) {
        result.addUnfilteredDestination(destination);
        result.removeFilteredDestination(destination, FilterSupport.createMessageFilter(oldArgs, destination));
    }
    result.addBinding(binding, newArguments);
}
Also used : MessageDestination(org.apache.qpid.server.message.MessageDestination)

Example 38 with MessageDestination

use of org.apache.qpid.server.message.MessageDestination in project qpid-broker-j by apache.

the class ConsumerTarget_0_10 method sendToDLQOrDiscard.

private void sendToDLQOrDiscard(final MessageInstanceConsumer consumer, MessageInstance entry) {
    final ServerMessage msg = entry.getMessage();
    int requeues = 0;
    if (entry.makeAcquisitionUnstealable(consumer)) {
        requeues = entry.routeToAlternate(new Action<MessageInstance>() {

            @Override
            public void performAction(final MessageInstance requeueEntry) {
                getEventLogger().message(ChannelMessages.DEADLETTERMSG(msg.getMessageNumber(), requeueEntry.getOwningResource().getName()));
            }
        }, null);
    }
    if (requeues == 0) {
        TransactionLogResource owningResource = entry.getOwningResource();
        if (owningResource instanceof Queue) {
            final Queue<?> queue = (Queue<?>) owningResource;
            final MessageDestination alternateBindingDestination = queue.getAlternateBindingDestination();
            if (alternateBindingDestination != null) {
                getEventLogger().message(ChannelMessages.DISCARDMSG_NOROUTE(msg.getMessageNumber(), alternateBindingDestination.getName()));
            } else {
                getEventLogger().message(ChannelMessages.DISCARDMSG_NOALTEXCH(msg.getMessageNumber(), queue.getName(), msg.getInitialRoutingAddress()));
            }
        }
    }
}
Also used : MessageInstance(org.apache.qpid.server.message.MessageInstance) Action(org.apache.qpid.server.util.Action) MessageDestination(org.apache.qpid.server.message.MessageDestination) ServerMessage(org.apache.qpid.server.message.ServerMessage) TransactionLogResource(org.apache.qpid.server.store.TransactionLogResource) Queue(org.apache.qpid.server.model.Queue)

Example 39 with MessageDestination

use of org.apache.qpid.server.message.MessageDestination in project qpid-broker-j by apache.

the class MessageConverter_Internal_to_v0_10 method convertToAndInitialRoutingKey.

private void convertToAndInitialRoutingKey(final InternalMessage serverMsg, final DeliveryProperties deliveryProps, final NamedAddressSpace addressSpace) {
    String to = serverMsg.getTo();
    final String exchangeName;
    final String routingKey;
    if (to == null || "".equals(to)) {
        to = serverMsg.getInitialRoutingAddress();
    }
    if (to != null && !"".equals(to)) {
        DestinationAddress destinationAddress = new DestinationAddress(addressSpace, to);
        MessageDestination messageDestination = destinationAddress.getMessageDestination();
        if (messageDestination instanceof Queue) {
            exchangeName = "";
            routingKey = messageDestination.getName();
        } else if (messageDestination instanceof Exchange) {
            exchangeName = messageDestination.getName();
            routingKey = destinationAddress.getRoutingKey();
        } else {
            exchangeName = "";
            routingKey = to;
        }
    } else {
        exchangeName = "";
        routingKey = "";
    }
    deliveryProps.setRoutingKey(ensureStr8("to' or 'initialRoutingAddress", routingKey));
    deliveryProps.setExchange(ensureStr8("to' or 'initialRoutingAddress", exchangeName));
}
Also used : Exchange(org.apache.qpid.server.model.Exchange) MessageDestination(org.apache.qpid.server.message.MessageDestination) Queue(org.apache.qpid.server.model.Queue) DestinationAddress(org.apache.qpid.server.model.DestinationAddress)

Example 40 with MessageDestination

use of org.apache.qpid.server.message.MessageDestination in project qpid-broker-j by apache.

the class MessageConverter_Internal_to_v0_10 method getReplyTo.

private ReplyTo getReplyTo(final NamedAddressSpace addressSpace, final String origReplyTo) {
    DestinationAddress destinationAddress = new DestinationAddress(addressSpace, origReplyTo);
    MessageDestination messageDestination = destinationAddress.getMessageDestination();
    final String exchange = ensureStr8("reply-to[\"exchange\"]", messageDestination instanceof Exchange ? messageDestination.getName() : "");
    final String routingKey = ensureStr8("reply-to[\"routing-key\"]", messageDestination instanceof Queue ? messageDestination.getName() : destinationAddress.getRoutingKey());
    return new ReplyTo(exchange, routingKey);
}
Also used : Exchange(org.apache.qpid.server.model.Exchange) ReplyTo(org.apache.qpid.server.protocol.v0_10.transport.ReplyTo) MessageDestination(org.apache.qpid.server.message.MessageDestination) Queue(org.apache.qpid.server.model.Queue) DestinationAddress(org.apache.qpid.server.model.DestinationAddress)

Aggregations

MessageDestination (org.apache.qpid.server.message.MessageDestination)40 DestinationAddress (org.apache.qpid.server.model.DestinationAddress)11 Queue (org.apache.qpid.server.model.Queue)11 Exchange (org.apache.qpid.server.model.Exchange)10 HashMap (java.util.HashMap)6 AbstractConfiguredObject (org.apache.qpid.server.model.AbstractConfiguredObject)6 Map (java.util.Map)5 AlternateBinding (org.apache.qpid.server.model.AlternateBinding)5 ConfiguredObject (org.apache.qpid.server.model.ConfiguredObject)5 AccessControlException (java.security.AccessControlException)4 HashSet (java.util.HashSet)4 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)4 RoutingResult (org.apache.qpid.server.message.RoutingResult)4 Binding (org.apache.qpid.server.model.Binding)4 NamedAddressSpace (org.apache.qpid.server.model.NamedAddressSpace)4 Set (java.util.Set)3 TopicExchangeResult (org.apache.qpid.server.exchange.topic.TopicExchangeResult)3 InstanceProperties (org.apache.qpid.server.message.InstanceProperties)3 ReplyTo (org.apache.qpid.server.protocol.v0_10.transport.ReplyTo)3 AMQShortString (org.apache.qpid.server.protocol.v0_8.AMQShortString)3