use of org.apache.qpid.server.model.DestinationAddress in project qpid-broker-j by apache.
the class MessageConverter_1_0_to_v0_8 method getReplyTo.
private AMQShortString getReplyTo(final Message_1_0 serverMsg, final NamedAddressSpace addressSpace) {
final String replyTo = serverMsg.getMessageHeader().getReplyTo();
if (replyTo != null) {
DestinationAddress destinationAddress = new DestinationAddress(addressSpace, replyTo);
MessageDestination messageDestination = destinationAddress.getMessageDestination();
final String replyToBindingUrl;
if (messageDestination instanceof Exchange) {
Exchange<?> exchange = (Exchange<?>) messageDestination;
final String routingKeyOption = "".equals(destinationAddress.getRoutingKey()) ? "" : String.format("?routingkey='%s'", destinationAddress.getRoutingKey());
replyToBindingUrl = String.format("%s://%s//%s", exchange.getType(), exchange.getName(), routingKeyOption);
} else if (messageDestination instanceof Queue) {
replyToBindingUrl = String.format("%s:////%s", ExchangeDefaults.DIRECT_EXCHANGE_CLASS, messageDestination.getName());
} else {
replyToBindingUrl = String.format("%s:////?routingkey='%s'", ExchangeDefaults.DIRECT_EXCHANGE_CLASS, destinationAddress.getRoutingKey());
}
try {
return AMQShortString.valueOf(replyToBindingUrl);
} catch (IllegalArgumentException e) {
throw new MessageConversionException("Could not convert message from 1.0 to 0-8 because conversion of 'reply-to' failed.", e);
}
}
return null;
}
use of org.apache.qpid.server.model.DestinationAddress in project qpid-broker-j by apache.
the class MessageConverter_1_0_to_v0_8 method createMessagePublishInfo.
private MessagePublishInfo createMessagePublishInfo(final MessageMetaData_1_0.MessageHeader_1_0 header, final NamedAddressSpace addressSpace) {
final String to = header.getTo();
final String subject = header.getSubject() == null ? "" : header.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;
}
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 MessageConverter_Internal_to_v0_8 method getReplyTo.
private String getReplyTo(final InternalMessage serverMsg, final NamedAddressSpace addressSpace) {
String replyTo = serverMsg.getMessageHeader().getReplyTo();
if (replyTo != null) {
DestinationAddress destinationAddress = new DestinationAddress(addressSpace, replyTo);
MessageDestination messageDestination = destinationAddress.getMessageDestination();
final String replyToBindingUrl;
if (messageDestination instanceof Exchange) {
Exchange<?> exchange = (Exchange<?>) messageDestination;
final String routingKeyOption = "".equals(destinationAddress.getRoutingKey()) ? "" : String.format("?routingkey='%s'", destinationAddress.getRoutingKey());
replyToBindingUrl = String.format("%s://%s//%s", exchange.getType(), exchange.getName(), routingKeyOption);
} else if (messageDestination instanceof Queue) {
replyToBindingUrl = String.format("%s:////%s", ExchangeDefaults.DIRECT_EXCHANGE_CLASS, messageDestination.getName());
} else {
replyToBindingUrl = String.format("%s:////?routingkey='%s'", ExchangeDefaults.DIRECT_EXCHANGE_CLASS, destinationAddress.getRoutingKey());
}
return replyToBindingUrl;
}
return null;
}
use of org.apache.qpid.server.model.DestinationAddress in project qpid-broker-j by apache.
the class Session_1_0 method getReceivingDestination.
public ReceivingDestination getReceivingDestination(final Link_1_0<?, ?> link, final Target target) throws AmqpErrorException {
final ReceivingDestination destination;
if (target != null) {
if (Boolean.TRUE.equals(target.getDynamic())) {
MessageDestination tempDestination = createDynamicDestination(link, target.getDynamicNodeProperties(), target.getCapabilities());
if (tempDestination != null) {
target.setAddress(_primaryDomain + tempDestination.getName());
} else {
throw new AmqpErrorException(AmqpError.INTERNAL_ERROR, "Cannot create dynamic destination");
}
}
String addr = target.getAddress();
if (addr == null || "".equals(addr.trim())) {
destination = new AnonymousRelayDestination(getAddressSpace(), target, _connection.getEventLogger());
} else {
DestinationAddress destinationAddress = new DestinationAddress(getAddressSpace(), addr);
MessageDestination messageDestination = destinationAddress.getMessageDestination();
if (messageDestination != null) {
destination = new NodeReceivingDestination(destinationAddress, target.getDurable(), target.getExpiryPolicy(), target.getCapabilities(), _connection.getEventLogger());
} else {
destination = null;
}
}
} else {
destination = null;
}
if (destination == null) {
throw new AmqpErrorException(AmqpError.NOT_FOUND, String.format("Could not find destination for target '%s'", target));
}
return destination;
}
use of org.apache.qpid.server.model.DestinationAddress 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));
}
Aggregations