git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@650766 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Davies 2008-04-23 07:10:22 +00:00
parent 18f9773326
commit 620b657216
2 changed files with 29 additions and 17 deletions

View File

@ -152,6 +152,7 @@ public class BrokerService implements Service {
private boolean keepDurableSubsActive = true; private boolean keepDurableSubsActive = true;
private boolean useVirtualTopics = true; private boolean useVirtualTopics = true;
private boolean useMirroredQueues = false; private boolean useMirroredQueues = false;
private boolean useTempMirroredQueues=true;
private BrokerId brokerId; private BrokerId brokerId;
private DestinationInterceptor[] destinationInterceptors; private DestinationInterceptor[] destinationInterceptors;
private ActiveMQDestination[] destinations; private ActiveMQDestination[] destinations;
@ -1303,6 +1304,14 @@ public class BrokerService implements Service {
int timeBeforePurgeTempDestinations) { int timeBeforePurgeTempDestinations) {
this.timeBeforePurgeTempDestinations = timeBeforePurgeTempDestinations; this.timeBeforePurgeTempDestinations = timeBeforePurgeTempDestinations;
} }
public boolean isUseTempMirroredQueues() {
return useTempMirroredQueues;
}
public void setUseTempMirroredQueues(boolean useTempMirroredQueues) {
this.useTempMirroredQueues = useTempMirroredQueues;
}
// //
// Implementation methods // Implementation methods
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
@ -1902,4 +1911,5 @@ public class BrokerService implements Service {
public void setRegionBroker(Broker regionBroker) { public void setRegionBroker(Broker regionBroker) {
this.regionBroker = regionBroker; this.regionBroker = regionBroker;
} }
} }

View File

@ -44,25 +44,27 @@ public class MirroredQueue implements DestinationInterceptor, BrokerServiceAware
public Destination intercept(final Destination destination) { public Destination intercept(final Destination destination) {
if (destination.getActiveMQDestination().isQueue()) { if (destination.getActiveMQDestination().isQueue()) {
try { if (!destination.getActiveMQDestination().isTemporary() || brokerService.isUseTempMirroredQueues()) {
final Destination mirrorDestination = getMirrorDestination(destination); try {
if (mirrorDestination != null) { final Destination mirrorDestination = getMirrorDestination(destination);
return new DestinationFilter(destination) { if (mirrorDestination != null) {
public void send(ProducerBrokerExchange context, Message message) throws Exception { return new DestinationFilter(destination) {
message.setDestination(mirrorDestination.getActiveMQDestination()); public void send(ProducerBrokerExchange context, Message message) throws Exception {
mirrorDestination.send(context, message); message.setDestination(mirrorDestination.getActiveMQDestination());
mirrorDestination.send(context, message);
if (isCopyMessage()) {
message = message.copy(); if (isCopyMessage()) {
message = message.copy();
}
message.setDestination(destination.getActiveMQDestination());
super.send(context, message);
} }
message.setDestination(destination.getActiveMQDestination()); };
super.send(context, message); }
} }
}; catch (Exception e) {
LOG.error("Failed to lookup the mirror destination for: " + destination + ". Reason: " + e, e);
} }
}
catch (Exception e) {
LOG.error("Failed to lookup the mirror destination for: " + destination + ". Reason: " + e, e);
} }
} }
return destination; return destination;