Search in sources :

Example 1 with ConfiguredDerivedMethodAttribute

use of org.apache.qpid.server.model.ConfiguredDerivedMethodAttribute in project qpid-broker-j by apache.

the class AbstractExchange method onOpen.

@Override
protected void onOpen() {
    super.onOpen();
    final ConfiguredDerivedMethodAttribute<Exchange<?>, Collection<Binding>> durableBindingsAttribute = (ConfiguredDerivedMethodAttribute<Exchange<?>, Collection<Binding>>) getModel().getTypeRegistry().getAttributeTypes(getTypeClass()).get(DURABLE_BINDINGS);
    final Collection<Binding> bindings = durableBindingsAttribute.convertValue(getActualAttributes().get(DURABLE_BINDINGS), this);
    if (bindings != null) {
        _bindings.addAll(bindings);
        for (Binding b : _bindings) {
            final MessageDestination messageDestination = getOpenedMessageDestination(b.getDestination());
            if (messageDestination != null) {
                Map<String, Object> arguments = b.getArguments() == null ? Collections.emptyMap() : b.getArguments();
                onBind(new BindingIdentifier(b.getBindingKey(), messageDestination), arguments);
                messageDestination.linkAdded(this, b);
            }
        }
    }
    if (getLifetimePolicy() == LifetimePolicy.DELETE_ON_CREATING_LINK_CLOSE) {
        if (_creatingLinkInfo != null) {
            final LinkModel link;
            if (_creatingLinkInfo.isSendingLink()) {
                link = _virtualHost.getSendingLink(_creatingLinkInfo.getRemoteContainerId(), _creatingLinkInfo.getLinkName());
            } else {
                link = _virtualHost.getReceivingLink(_creatingLinkInfo.getRemoteContainerId(), _creatingLinkInfo.getLinkName());
            }
            addLifetimeConstraint(link);
        } else {
            throw new IllegalArgumentException("Exchanges created with a lifetime policy of " + getLifetimePolicy() + " must be created from a AMQP 1.0 link.");
        }
    }
    if (getAlternateBinding() != null) {
        String alternateDestination = getAlternateBinding().getDestination();
        _alternateBindingDestination = getOpenedMessageDestination(alternateDestination);
        if (_alternateBindingDestination != null) {
            _alternateBindingDestination.addReference(this);
        } else {
            LOGGER.warn("Cannot find alternate binding destination '{}' for exchange '{}'", alternateDestination, toString());
        }
    }
    getEventLogger().message(ExchangeMessages.CREATED(getType(), getName(), isDurable()));
}
Also used : Binding(org.apache.qpid.server.model.Binding) AlternateBinding(org.apache.qpid.server.model.AlternateBinding) MessageDestination(org.apache.qpid.server.message.MessageDestination) LinkModel(org.apache.qpid.server.protocol.LinkModel) Exchange(org.apache.qpid.server.model.Exchange) ConfiguredDerivedMethodAttribute(org.apache.qpid.server.model.ConfiguredDerivedMethodAttribute) Collection(java.util.Collection) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) AbstractConfiguredObject(org.apache.qpid.server.model.AbstractConfiguredObject)

Aggregations

Collection (java.util.Collection)1 MessageDestination (org.apache.qpid.server.message.MessageDestination)1 AbstractConfiguredObject (org.apache.qpid.server.model.AbstractConfiguredObject)1 AlternateBinding (org.apache.qpid.server.model.AlternateBinding)1 Binding (org.apache.qpid.server.model.Binding)1 ConfiguredDerivedMethodAttribute (org.apache.qpid.server.model.ConfiguredDerivedMethodAttribute)1 ConfiguredObject (org.apache.qpid.server.model.ConfiguredObject)1 Exchange (org.apache.qpid.server.model.Exchange)1 LinkModel (org.apache.qpid.server.protocol.LinkModel)1