mirror of https://github.com/apache/activemq.git
Reduce contention by not sending an advisory for every destination when not all destination types are requested. git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1214964 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
41cdadbe2a
commit
68bcf0fb15
|
@ -96,15 +96,23 @@ public class AdvisoryBroker extends BrokerFilter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// We need to replay all the previously collected destination
|
// We check here whether the Destination is Temporary Destination specific or not since we
|
||||||
// objects
|
// can avoid sending advisory messages to the consumer if it only wants Temporary Destination
|
||||||
// for this newly added consumer.
|
// notifications. If its not just temporary destination related destinations then we have
|
||||||
if (AdvisorySupport.isDestinationAdvisoryTopic(info.getDestination())) {
|
// to send them all, a composite destination could want both.
|
||||||
// Replay the destinations.
|
if (AdvisorySupport.isTempDestinationAdvisoryTopic(info.getDestination())) {
|
||||||
for (Iterator<DestinationInfo> iter = destinations.values().iterator(); iter.hasNext();) {
|
// Replay the temporary destinations.
|
||||||
DestinationInfo value = iter.next();
|
for (DestinationInfo destination : destinations.values()) {
|
||||||
ActiveMQTopic topic = AdvisorySupport.getDestinationAdvisoryTopic(value.getDestination());
|
if (destination.getDestination().isTemporary()) {
|
||||||
fireAdvisory(context, topic, value, info.getConsumerId());
|
ActiveMQTopic topic = AdvisorySupport.getDestinationAdvisoryTopic(destination.getDestination());
|
||||||
|
fireAdvisory(context, topic, destination, info.getConsumerId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (AdvisorySupport.isDestinationAdvisoryTopic(info.getDestination())) {
|
||||||
|
// Replay all the destinations.
|
||||||
|
for (DestinationInfo destination : destinations.values()) {
|
||||||
|
ActiveMQTopic topic = AdvisorySupport.getDestinationAdvisoryTopic(destination.getDestination());
|
||||||
|
fireAdvisory(context, topic, destination, info.getConsumerId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -243,7 +251,7 @@ public class AdvisoryBroker extends BrokerFilter {
|
||||||
ActiveMQTopic topic = AdvisorySupport.getConsumerAdvisoryTopic(dest);
|
ActiveMQTopic topic = AdvisorySupport.getConsumerAdvisoryTopic(dest);
|
||||||
consumers.remove(info.getConsumerId());
|
consumers.remove(info.getConsumerId());
|
||||||
if (!dest.isTemporary() || destinations.containsKey(dest)) {
|
if (!dest.isTemporary() || destinations.containsKey(dest)) {
|
||||||
fireConsumerAdvisory(context,dest, topic, info.createRemoveCommand());
|
fireConsumerAdvisory(context,dest, topic, info.createRemoveCommand());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,6 +60,9 @@ public final class AdvisorySupport {
|
||||||
public static final String MSG_PROPERTY_CONSUMER_COUNT = "consumerCount";
|
public static final String MSG_PROPERTY_CONSUMER_COUNT = "consumerCount";
|
||||||
public static final String MSG_PROPERTY_DISCARDED_COUNT = "discardedCount";
|
public static final String MSG_PROPERTY_DISCARDED_COUNT = "discardedCount";
|
||||||
|
|
||||||
|
public static final ActiveMQTopic ALL_DESTINATIONS_COMPOSITE_ADVISORY_TOPIC = new ActiveMQTopic(
|
||||||
|
TOPIC_ADVISORY_TOPIC.getPhysicalName() + "," + QUEUE_ADVISORY_TOPIC.getPhysicalName() + "," +
|
||||||
|
TEMP_QUEUE_ADVISORY_TOPIC.getPhysicalName() + "," + TEMP_TOPIC_ADVISORY_TOPIC.getPhysicalName());
|
||||||
public static final ActiveMQTopic TEMP_DESTINATION_COMPOSITE_ADVISORY_TOPIC = new ActiveMQTopic(
|
public static final ActiveMQTopic TEMP_DESTINATION_COMPOSITE_ADVISORY_TOPIC = new ActiveMQTopic(
|
||||||
TEMP_QUEUE_ADVISORY_TOPIC.getPhysicalName() + "," + TEMP_TOPIC_ADVISORY_TOPIC.getPhysicalName());
|
TEMP_QUEUE_ADVISORY_TOPIC.getPhysicalName() + "," + TEMP_TOPIC_ADVISORY_TOPIC.getPhysicalName());
|
||||||
private static final ActiveMQTopic AGENT_TOPIC_DESTINATION = new ActiveMQTopic(AGENT_TOPIC);
|
private static final ActiveMQTopic AGENT_TOPIC_DESTINATION = new ActiveMQTopic(AGENT_TOPIC);
|
||||||
|
@ -239,6 +242,20 @@ public final class AdvisorySupport {
|
||||||
return isDestinationAdvisoryTopic(ActiveMQMessageTransformation.transformDestination(destination));
|
return isDestinationAdvisoryTopic(ActiveMQMessageTransformation.transformDestination(destination));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isTempDestinationAdvisoryTopic(ActiveMQDestination destination) {
|
||||||
|
if (destination.isComposite()) {
|
||||||
|
ActiveMQDestination[] compositeDestinations = destination.getCompositeDestinations();
|
||||||
|
for (int i = 0; i < compositeDestinations.length; i++) {
|
||||||
|
if (!isTempDestinationAdvisoryTopic(compositeDestinations[i])) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return destination.equals(TEMP_QUEUE_ADVISORY_TOPIC) || destination.equals(TEMP_TOPIC_ADVISORY_TOPIC);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isDestinationAdvisoryTopic(ActiveMQDestination destination) {
|
public static boolean isDestinationAdvisoryTopic(ActiveMQDestination destination) {
|
||||||
if (destination.isComposite()) {
|
if (destination.isComposite()) {
|
||||||
ActiveMQDestination[] compositeDestinations = destination.getCompositeDestinations();
|
ActiveMQDestination[] compositeDestinations = destination.getCompositeDestinations();
|
||||||
|
|
Loading…
Reference in New Issue