Search in sources :

Example 1 with DestinationAddress

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));
}
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 2 with DestinationAddress

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;
}
Also used : RoutingResult(org.apache.qpid.server.message.RoutingResult) MessageDestination(org.apache.qpid.server.message.MessageDestination) DestinationAddress(org.apache.qpid.server.model.DestinationAddress)

Example 3 with DestinationAddress

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));
}
Also used : Exchange(org.apache.qpid.server.model.Exchange) MessagePublishInfo(org.apache.qpid.server.protocol.v0_8.transport.MessagePublishInfo) MessageDestination(org.apache.qpid.server.message.MessageDestination) Queue(org.apache.qpid.server.model.Queue) DestinationAddress(org.apache.qpid.server.model.DestinationAddress)

Example 4 with DestinationAddress

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);
    }
}
Also used : MessageDestination(org.apache.qpid.server.message.MessageDestination) DestinationAddress(org.apache.qpid.server.model.DestinationAddress)

Example 5 with DestinationAddress

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()));
}
Also used : ReplyTo(org.apache.qpid.server.protocol.v0_10.transport.ReplyTo) 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)

Aggregations

MessageDestination (org.apache.qpid.server.message.MessageDestination)11 DestinationAddress (org.apache.qpid.server.model.DestinationAddress)11 Exchange (org.apache.qpid.server.model.Exchange)8 Queue (org.apache.qpid.server.model.Queue)8 ReplyTo (org.apache.qpid.server.protocol.v0_10.transport.ReplyTo)2 AMQShortString (org.apache.qpid.server.protocol.v0_8.AMQShortString)2 MessagePublishInfo (org.apache.qpid.server.protocol.v0_8.transport.MessagePublishInfo)2 RoutingResult (org.apache.qpid.server.message.RoutingResult)1 MessageConversionException (org.apache.qpid.server.protocol.converter.MessageConversionException)1 AmqpErrorException (org.apache.qpid.server.protocol.v1_0.type.AmqpErrorException)1