use of org.apache.activemq.artemis.core.postoffice.Bindings in project activemq-artemis by apache.
the class SimpleAddressManager method validateRoutingTypes.
private void validateRoutingTypes(SimpleString addressName, EnumSet<RoutingType> routingTypes) {
final Bindings bindings = this.mappings.get(addressName);
if (bindings != null) {
for (Binding binding : bindings.getBindings()) {
if (binding instanceof QueueBinding) {
final QueueBinding queueBinding = (QueueBinding) binding;
final RoutingType routingType = queueBinding.getQueue().getRoutingType();
if (!routingTypes.contains(routingType) && binding.getAddress().equals(addressName)) {
throw ActiveMQMessageBundle.BUNDLE.invalidRoutingTypeDelete(routingType, addressName.toString());
}
}
}
}
}
use of org.apache.activemq.artemis.core.postoffice.Bindings in project activemq-artemis by apache.
the class SimpleAddressManager method getMatchingBindings.
@Override
public Bindings getMatchingBindings(final SimpleString address) throws Exception {
Address add = new AddressImpl(address, wildcardConfiguration);
Bindings bindings = bindingsFactory.createBindings(address);
for (Binding binding : nameMap.values()) {
Address addCheck = new AddressImpl(binding.getAddress(), wildcardConfiguration);
if (addCheck.matches(add)) {
bindings.addBinding(binding);
}
}
return bindings;
}
use of org.apache.activemq.artemis.core.postoffice.Bindings in project activemq-artemis by apache.
the class SimpleAddressManager method addMappingInternal.
protected boolean addMappingInternal(final SimpleString address, final Binding binding) throws Exception {
Bindings bindings = mappings.get(address);
Bindings prevBindings = null;
if (bindings == null) {
bindings = bindingsFactory.createBindings(address);
prevBindings = mappings.putIfAbsent(address, bindings);
if (prevBindings != null) {
bindings = prevBindings;
}
}
bindings.addBinding(binding);
return prevBindings != null;
}
use of org.apache.activemq.artemis.core.postoffice.Bindings in project activemq-artemis by apache.
the class AddressControlImpl method getQueueNames.
@Override
public String[] getQueueNames() throws Exception {
clearIO();
try {
Bindings bindings = postOffice.getBindingsForAddress(addressInfo.getName());
List<String> queueNames = new ArrayList<>();
for (Binding binding : bindings.getBindings()) {
if (binding instanceof QueueBinding) {
queueNames.add(binding.getUniqueName().toString());
}
}
return queueNames.toArray(new String[queueNames.size()]);
} catch (Throwable t) {
throw new IllegalStateException(t.getMessage());
} finally {
blockOnIO();
}
}
use of org.apache.activemq.artemis.core.postoffice.Bindings in project activemq-artemis by apache.
the class OpenWireConnection method removeDestination.
public void removeDestination(ActiveMQDestination dest) throws Exception {
if (dest.isQueue()) {
try {
server.destroyQueue(new SimpleString(dest.getPhysicalName()), getRemotingConnection());
} catch (ActiveMQNonExistentQueueException neq) {
// this is ok, ActiveMQ 5 allows this and will actually do it quite often
ActiveMQServerLogger.LOGGER.debug("queue never existed");
}
} else {
Bindings bindings = server.getPostOffice().getBindingsForAddress(new SimpleString(dest.getPhysicalName()));
for (Binding binding : bindings.getBindings()) {
Queue b = (Queue) binding.getBindable();
if (b.getConsumerCount() > 0) {
throw new Exception("Destination still has an active subscription: " + dest.getPhysicalName());
}
if (b.isDurable()) {
throw new Exception("Destination still has durable subscription: " + dest.getPhysicalName());
}
b.deleteQueue();
}
}
if (!AdvisorySupport.isAdvisoryTopic(dest)) {
AMQConnectionContext context = getContext();
DestinationInfo advInfo = new DestinationInfo(context.getConnectionId(), DestinationInfo.REMOVE_OPERATION_TYPE, dest);
ActiveMQTopic topic = AdvisorySupport.getDestinationAdvisoryTopic(dest);
protocolManager.fireAdvisory(context, topic, advInfo);
}
}
Aggregations