use of org.apache.activemq.artemis.core.postoffice.Address in project activemq-artemis by apache.
the class WildcardAddressManager method getAddress.
private Address getAddress(final SimpleString address) {
Address add = new AddressImpl(address, wildcardConfiguration);
Address actualAddress;
if (add.containsWildCard()) {
actualAddress = wildCardAddresses.get(address);
} else {
actualAddress = addresses.get(address);
}
return actualAddress != null ? actualAddress : add;
}
use of org.apache.activemq.artemis.core.postoffice.Address in project activemq-artemis by apache.
the class WildcardAddressManager method removeAndUpdateAddressMap.
private synchronized void removeAndUpdateAddressMap(final Address address) throws Exception {
// we only remove if there are no bindings left
Bindings bindings = super.getBindingsForRoutingAddress(address.getAddress());
if (bindings == null || bindings.getBindings().size() == 0) {
List<Address> addresses = address.getLinkedAddresses();
for (Address address1 : addresses) {
address1.removeLinkedAddress(address);
Bindings linkedBindings = super.getBindingsForRoutingAddress(address1.getAddress());
if (linkedBindings == null || linkedBindings.getBindings().size() == 0) {
removeAddress(address1);
}
}
removeAddress(address);
}
}
use of org.apache.activemq.artemis.core.postoffice.Address in project activemq-artemis by apache.
the class WildcardAddressManager method removeBinding.
/**
* If the address is a wild card then the binding will be removed from the actual mappings for any linked address.
* otherwise it will be removed as normal.
*
* @param uniqueName the name of the binding to remove
* @return true if this was the last mapping for a specific address
*/
@Override
public Binding removeBinding(final SimpleString uniqueName, Transaction tx) throws Exception {
Binding binding = super.removeBinding(uniqueName, tx);
if (binding != null) {
Address add = getAddress(binding.getAddress());
if (add.containsWildCard()) {
for (Address theAddress : add.getLinkedAddresses()) {
super.removeBindingInternal(theAddress.getAddress(), uniqueName);
}
}
removeAndUpdateAddressMap(add);
}
return binding;
}
use of org.apache.activemq.artemis.core.postoffice.Address in project activemq-artemis by apache.
the class WildcardAddressManager method addAndUpdateAddressMap.
private synchronized Address addAndUpdateAddressMap(final SimpleString address) {
Address add = new AddressImpl(address, wildcardConfiguration);
Address actualAddress;
if (add.containsWildCard()) {
actualAddress = wildCardAddresses.get(address);
} else {
actualAddress = addresses.get(address);
}
if (actualAddress == null) {
actualAddress = add;
addAddress(address, actualAddress);
}
if (actualAddress.containsWildCard()) {
for (Address destAdd : addresses.values()) {
if (destAdd.matches(actualAddress)) {
destAdd.addLinkedAddress(actualAddress);
actualAddress.addLinkedAddress(destAdd);
}
}
} else {
for (Address destAdd : wildCardAddresses.values()) {
if (actualAddress.matches(destAdd)) {
destAdd.addLinkedAddress(actualAddress);
actualAddress.addLinkedAddress(destAdd);
}
}
}
return actualAddress;
}
use of org.apache.activemq.artemis.core.postoffice.Address in project activemq-artemis by apache.
the class WildcardAddressManager method updateMessageLoadBalancingTypeForAddress.
@Override
public void updateMessageLoadBalancingTypeForAddress(SimpleString address, MessageLoadBalancingType messageLoadBalancingType) throws Exception {
Address add = addAndUpdateAddressMap(address);
Bindings bindingsForRoutingAddress = super.getBindingsForRoutingAddress(address);
if (bindingsForRoutingAddress != null) {
bindingsForRoutingAddress.setMessageLoadBalancingType(messageLoadBalancingType);
}
if (add.containsWildCard()) {
for (Address destAdd : add.getLinkedAddresses()) {
getBindingsForRoutingAddress(destAdd.getAddress()).setMessageLoadBalancingType(messageLoadBalancingType);
}
} else {
for (Address destAdd : add.getLinkedAddresses()) {
super.getBindingsForRoutingAddress(destAdd.getAddress()).setMessageLoadBalancingType(messageLoadBalancingType);
}
}
}
Aggregations