use of org.apache.qpid.server.model.DestinationAddress in project qpid-broker-j by apache.
the class MessageConverter_1_0_to_v0_10 method setExchangeAndRoutingKeyOnDeliveryProperties.
private void setExchangeAndRoutingKeyOnDeliveryProperties(final DeliveryProperties deliveryProps, final MessageMetaData_1_0.MessageHeader_1_0 origHeader, final NamedAddressSpace addressSpace) {
final String to = origHeader.getTo();
final String subject = origHeader.getSubject() == null ? "" : origHeader.getSubject();
final String exchangeName;
final String routingKey;
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 = "".equals(destinationAddress.getRoutingKey()) ? subject : destinationAddress.getRoutingKey();
} else {
exchangeName = "";
routingKey = to;
}
} else {
exchangeName = "";
routingKey = subject;
}
deliveryProps.setRoutingKey(ensureStr8("to' or 'subject", routingKey));
deliveryProps.setExchange(ensureStr8("to", exchangeName));
}
use of org.apache.qpid.server.model.DestinationAddress in project qpid-broker-j by apache.
the class DefaultDestination method route.
@Override
public <M extends ServerMessage<? extends StorableMessageMetaData>> RoutingResult<M> route(M message, String routingAddress, InstanceProperties instanceProperties) {
RoutingResult<M> result = new RoutingResult<>(message);
DestinationAddress destinationAddress = new DestinationAddress(_virtualHost, routingAddress);
MessageDestination messageDestination = destinationAddress.getMessageDestination();
if (messageDestination != null) {
result.add(messageDestination.route(message, destinationAddress.getRoutingKey(), instanceProperties));
}
return result;
}
use of org.apache.qpid.server.model.DestinationAddress in project qpid-broker-j by apache.
the class MessageConverter_Internal_to_v0_8 method createMessagePublishInfo.
private MessagePublishInfo createMessagePublishInfo(final InternalMessage serverMsg, 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 = "";
}
return new MessagePublishInfo(convertToShortStringForProperty("to", exchangeName), false, false, convertToShortStringForProperty("to' or 'subject", routingKey));
}
use of org.apache.qpid.server.model.DestinationAddress in project qpid-broker-j by apache.
the class AnonymousRelayDestination method send.
@Override
public void send(final ServerMessage<?> message, final ServerTransaction txn, final SecurityToken securityToken) throws UnroutableMessageException {
final ReceivingDestination destination;
final String routingAddress = message.getTo();
DestinationAddress destinationAddress = new DestinationAddress(_addressSpace, routingAddress);
MessageDestination messageDestination = destinationAddress.getMessageDestination();
if (messageDestination != null) {
destination = new NodeReceivingDestination(destinationAddress, _target.getDurable(), _target.getExpiryPolicy(), _target.getCapabilities(), _eventLogger);
} else {
destination = null;
}
if (destination == null) {
if (_discardUnroutable) {
_eventLogger.message(ExchangeMessages.DISCARDMSG("", routingAddress));
} else {
throw new UnroutableMessageException(AmqpError.NOT_FOUND, String.format("Unknown destination '%s'", routingAddress));
}
} else {
destination.send(message, txn, securityToken);
}
}
use of org.apache.qpid.server.model.DestinationAddress in project qpid-broker-j by apache.
the class MessageConverter_1_0_to_v0_10 method getReplyTo.
private ReplyTo getReplyTo(final NamedAddressSpace addressSpace, final String origReplyTo) {
DestinationAddress destinationAddress = new DestinationAddress(addressSpace, origReplyTo);
MessageDestination messageDestination = destinationAddress.getMessageDestination();
return new ReplyTo(ensureStr8("reply-to[\"exchange\"]", messageDestination instanceof Exchange ? messageDestination.getName() : ""), ensureStr8("reply-to[\"routing-key\"]", messageDestination instanceof Queue ? messageDestination.getName() : destinationAddress.getRoutingKey()));
}
Aggregations