https://issues.apache.org/jira/browse/AMQ-6331 - Honor excluded destinations in static routing on network connectors

This commit is contained in:
Dejan Bosanac 2016-06-21 15:07:30 +02:00
parent 27d955501f
commit 1faa4afa90
2 changed files with 73 additions and 50 deletions

View File

@ -1009,7 +1009,7 @@ public abstract class DemandForwardingBridgeSupport implements NetworkBridge, Br
}
return;
}
if (isPermissableDestination(md.getDestination())) {
if (message.isPersistent() || configuration.isAlwaysSyncSend()) {
// The message was not sent using async send, so we should only
@ -1048,6 +1048,7 @@ public abstract class DemandForwardingBridgeSupport implements NetworkBridge, Br
}
}
serviceOutbound(message);
}
} else {
LOG.debug("No subscription registered with this network bridge for consumerId: {} for message: {}", md.getConsumerId(), md.getMessage());
}
@ -1132,17 +1133,7 @@ public abstract class DemandForwardingBridgeSupport implements NetworkBridge, Br
}
}
ActiveMQDestination[] dests = staticallyIncludedDestinations;
if (dests != null && dests.length > 0) {
for (ActiveMQDestination dest : dests) {
DestinationFilter inclusionFilter = DestinationFilter.parseFilter(dest);
if (dest != null && inclusionFilter.matches(destination) && dest.getDestinationType() == destination.getDestinationType()) {
return true;
}
}
}
dests = excludedDestinations;
ActiveMQDestination[] dests = excludedDestinations;
if (dests != null && dests.length > 0) {
for (ActiveMQDestination dest : dests) {
DestinationFilter exclusionFilter = DestinationFilter.parseFilter(dest);
@ -1152,6 +1143,16 @@ public abstract class DemandForwardingBridgeSupport implements NetworkBridge, Br
}
}
dests = staticallyIncludedDestinations;
if (dests != null && dests.length > 0) {
for (ActiveMQDestination dest : dests) {
DestinationFilter inclusionFilter = DestinationFilter.parseFilter(dest);
if (dest != null && inclusionFilter.matches(destination) && dest.getDestinationType() == destination.getDestinationType()) {
return true;
}
}
}
dests = dynamicallyIncludedDestinations;
if (dests != null && dests.length > 0) {
for (ActiveMQDestination dest : dests) {
@ -1173,6 +1174,7 @@ public abstract class DemandForwardingBridgeSupport implements NetworkBridge, Br
ActiveMQDestination[] dests = staticallyIncludedDestinations;
if (dests != null) {
for (ActiveMQDestination dest : dests) {
if (isPermissableDestination(dest)) {
DemandSubscription sub = createDemandSubscription(dest);
sub.setStaticallyIncluded(true);
try {
@ -1181,6 +1183,9 @@ public abstract class DemandForwardingBridgeSupport implements NetworkBridge, Br
LOG.error("Failed to add static destination {}", dest, e);
}
LOG.trace("{}, bridging messages for static destination: {}", configuration.getBrokerName(), dest);
} else {
LOG.info("{}, static destination excluded: {}", configuration.getBrokerName(), dest);
}
}
}
}

View File

@ -117,6 +117,24 @@ public class DemandForwardingBridgeFilterTest extends NetworkTestSupport {
assertReceiveNoMessageOn("OTHER.T2", ActiveMQDestination.TOPIC_TYPE);
}
public void testExcludeStaticDestinations() throws Exception {
NetworkBridgeConfiguration configuration = getDefaultBridgeConfiguration();
configuration.setExcludedDestinations(Arrays.asList(ActiveMQDestination.createDestination("TEST.X1", ActiveMQDestination.QUEUE_TYPE), ActiveMQDestination.createDestination("OTHER.X1", ActiveMQDestination.QUEUE_TYPE)));
configuration.setStaticallyIncludedDestinations(Arrays.asList(ActiveMQDestination.createDestination(
"TEST.>", ActiveMQDestination.QUEUE_TYPE), ActiveMQDestination.createDestination(
"OTHER.X1", ActiveMQDestination.QUEUE_TYPE), ActiveMQDestination.createDestination(
"OTHER.X2", ActiveMQDestination.QUEUE_TYPE)));
configureAndStartBridge(configuration);
assertReceiveNoMessageOn("TEST.X1", ActiveMQDestination.QUEUE_TYPE);
assertReceiveMessageOn("TEST.X2", ActiveMQDestination.QUEUE_TYPE);
assertReceiveNoMessageOn("OTHER.X1", ActiveMQDestination.QUEUE_TYPE);
assertReceiveMessageOn("OTHER.X2", ActiveMQDestination.QUEUE_TYPE);
}
private void assertReceiveMessageOn(String destinationName, byte destinationType) throws Exception,
InterruptedException {