use of org.apache.activemq.artemis.core.postoffice.Binding in project activemq-artemis by apache.
the class BindingsImpl method addBinding.
@Override
public void addBinding(final Binding binding) {
if (logger.isTraceEnabled()) {
logger.trace("addBinding(" + binding + ") being called");
}
if (binding.isExclusive()) {
exclusiveBindings.add(binding);
} else {
SimpleString routingName = binding.getRoutingName();
List<Binding> bindings = routingNameBindingMap.get(routingName);
if (bindings == null) {
bindings = new CopyOnWriteArrayList<>();
List<Binding> oldBindings = routingNameBindingMap.putIfAbsent(routingName, bindings);
if (oldBindings != null) {
bindings = oldBindings;
}
}
if (!bindings.contains(binding)) {
bindings.add(binding);
}
}
bindingsMap.put(binding.getID(), binding);
if (logger.isTraceEnabled()) {
logger.trace("Adding binding " + binding + " into " + this + " bindingTable: " + debugBindings());
}
}
use of org.apache.activemq.artemis.core.postoffice.Binding 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.Binding in project activemq-artemis by apache.
the class SimpleAddressManager method removeBinding.
@Override
public Binding removeBinding(final SimpleString uniqueName, Transaction tx) throws Exception {
final Binding binding = nameMap.remove(uniqueName);
if (binding == null) {
return null;
}
removeBindingInternal(binding.getAddress(), uniqueName);
return binding;
}
use of org.apache.activemq.artemis.core.postoffice.Binding 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.Binding 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();
}
}
Aggregations