Search in sources :

Example 6 with UnknownAlternateBindingException

use of org.apache.qpid.server.virtualhost.UnknownAlternateBindingException in project qpid-broker-j by apache.

the class AbstractExchange method validateOrCreateAlternateBinding.

private void validateOrCreateAlternateBinding(final Exchange<?> exchange, final boolean mayCreate) {
    Object value = exchange.getAttribute(ALTERNATE_BINDING);
    if (value instanceof AlternateBinding) {
        AlternateBinding alternateBinding = (AlternateBinding) value;
        String destinationName = alternateBinding.getDestination();
        MessageDestination messageDestination = _virtualHost.getAttainedMessageDestination(destinationName, mayCreate);
        if (messageDestination == null) {
            throw new UnknownAlternateBindingException(destinationName);
        } else if (messageDestination == this) {
            throw new IllegalConfigurationException(String.format("Cannot create alternate binding for '%s' : Alternate binding destination cannot refer to self.", getName()));
        } else if (isDurable() && !messageDestination.isDurable()) {
            throw new IllegalConfigurationException(String.format("Cannot create alternate binding for '%s' : Alternate binding destination '%s' is not durable.", getName(), destinationName));
        }
    }
}
Also used : MessageDestination(org.apache.qpid.server.message.MessageDestination) AlternateBinding(org.apache.qpid.server.model.AlternateBinding) IllegalConfigurationException(org.apache.qpid.server.configuration.IllegalConfigurationException) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) AbstractConfiguredObject(org.apache.qpid.server.model.AbstractConfiguredObject) UnknownAlternateBindingException(org.apache.qpid.server.virtualhost.UnknownAlternateBindingException)

Aggregations

IllegalConfigurationException (org.apache.qpid.server.configuration.IllegalConfigurationException)6 UnknownAlternateBindingException (org.apache.qpid.server.virtualhost.UnknownAlternateBindingException)6 AbstractConfiguredObject (org.apache.qpid.server.model.AbstractConfiguredObject)5 AccessControlException (java.security.AccessControlException)4 NamedAddressSpace (org.apache.qpid.server.model.NamedAddressSpace)4 HashMap (java.util.HashMap)2 LinkedHashMap (java.util.LinkedHashMap)2 MessageDestination (org.apache.qpid.server.message.MessageDestination)2 Exchange (org.apache.qpid.server.model.Exchange)2 ExclusivityPolicy (org.apache.qpid.server.model.ExclusivityPolicy)2 LifetimePolicy (org.apache.qpid.server.model.LifetimePolicy)2 NoFactoryForTypeException (org.apache.qpid.server.model.NoFactoryForTypeException)2 Queue (org.apache.qpid.server.model.Queue)2 ReservedExchangeNameException (org.apache.qpid.server.virtualhost.ReservedExchangeNameException)2 ConcurrentLinkedQueue (java.util.concurrent.ConcurrentLinkedQueue)1 AlternateBinding (org.apache.qpid.server.model.AlternateBinding)1 ConfiguredObject (org.apache.qpid.server.model.ConfiguredObject)1