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);
}
}
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);
}
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()));
}
}
}
}
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));
}
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);
}
Aggregations