use of org.apache.qpid.server.protocol.v1_0.type.LifetimePolicy in project qpid-broker-j by apache.
the class ExchangeSendingDestination method getQueue.
private static Queue<?> getQueue(Exchange<?> exchange, Source source, String subscriptionName, BindingInfo bindingInfo) throws AmqpErrorException {
boolean isDurable = source.getExpiryPolicy() == TerminusExpiryPolicy.NEVER;
boolean isShared = hasCapability(source.getCapabilities(), SHARED_CAPABILITY);
QueueManagingVirtualHost virtualHost;
if (exchange.getAddressSpace() instanceof QueueManagingVirtualHost) {
virtualHost = (QueueManagingVirtualHost) exchange.getAddressSpace();
} else {
throw new AmqpErrorException(new Error(AmqpError.INTERNAL_ERROR, "Address space of unexpected type"));
}
Queue<?> queue;
final Map<String, Object> attributes = new HashMap<>();
ExclusivityPolicy exclusivityPolicy;
if (isShared) {
exclusivityPolicy = ExclusivityPolicy.SHARED_SUBSCRIPTION;
} else {
exclusivityPolicy = ExclusivityPolicy.LINK;
}
org.apache.qpid.server.model.LifetimePolicy lifetimePolicy = getLifetimePolicy(source.getExpiryPolicy());
attributes.put(Queue.ID, UUID.randomUUID());
attributes.put(Queue.NAME, subscriptionName);
attributes.put(Queue.LIFETIME_POLICY, lifetimePolicy);
attributes.put(Queue.EXCLUSIVE, exclusivityPolicy);
attributes.put(Queue.DURABLE, isDurable);
Map<String, Map<String, Object>> bindings = bindingInfo.getBindings();
try {
queue = virtualHost.getSubscriptionQueue(exchange.getName(), attributes, bindings);
} catch (NotFoundException e) {
throw new AmqpErrorException(new Error(AmqpError.NOT_FOUND, e.getMessage()));
} catch (IllegalStateException e) {
throw new AmqpErrorException(new Error(AmqpError.RESOURCE_LOCKED, "Subscription is already in use"));
}
return queue;
}
use of org.apache.qpid.server.protocol.v1_0.type.LifetimePolicy in project qpid-broker-j by apache.
the class Session_1_0 method convertDynamicNodePropertiesToAttributes.
private Map<String, Object> convertDynamicNodePropertiesToAttributes(final Link_1_0<?, ?> link, final Map properties, final String nodeName) {
// TODO convert AMQP 1-0 node properties to queue attributes
LifetimePolicy lifetimePolicy = properties == null ? null : (LifetimePolicy) properties.get(LIFETIME_POLICY);
Map<String, Object> attributes = new HashMap<>();
attributes.put(ConfiguredObject.ID, UUID.randomUUID());
attributes.put(ConfiguredObject.NAME, nodeName);
attributes.put(ConfiguredObject.DURABLE, true);
if (lifetimePolicy instanceof DeleteOnNoLinks) {
attributes.put(ConfiguredObject.LIFETIME_POLICY, org.apache.qpid.server.model.LifetimePolicy.DELETE_ON_NO_LINKS);
} else if (lifetimePolicy instanceof DeleteOnNoLinksOrMessages) {
attributes.put(ConfiguredObject.LIFETIME_POLICY, org.apache.qpid.server.model.LifetimePolicy.IN_USE);
} else if (lifetimePolicy instanceof DeleteOnClose) {
attributes.put(ConfiguredObject.LIFETIME_POLICY, org.apache.qpid.server.model.LifetimePolicy.DELETE_ON_CREATING_LINK_CLOSE);
final CreatingLinkInfo linkInfo = new CreatingLinkInfoImpl(link.getRole() == Role.SENDER, link.getRemoteContainerId(), link.getName());
attributes.put("creatingLinkInfo", linkInfo);
} else if (lifetimePolicy instanceof DeleteOnNoMessages) {
attributes.put(ConfiguredObject.LIFETIME_POLICY, org.apache.qpid.server.model.LifetimePolicy.IN_USE);
} else {
attributes.put(ConfiguredObject.LIFETIME_POLICY, org.apache.qpid.server.model.LifetimePolicy.DELETE_ON_CONNECTION_CLOSE);
}
return attributes;
}
Aggregations