Skip to content

Commit

Permalink
[AMQ-8354] Fix NPE on removing consumers.
Browse files Browse the repository at this point in the history
  • Loading branch information
NikitaShupletsov committed Aug 8, 2024
1 parent d6dea41 commit d4811b7
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.apache.activemq.broker.jmx.QueueView;
import org.apache.activemq.broker.jmx.TopicView;
import org.apache.activemq.broker.region.Destination;
import org.apache.activemq.broker.region.RegionBroker;
import org.apache.activemq.broker.region.Subscription;
import org.apache.activemq.command.ActiveMQDestination;
import org.apache.activemq.command.ConsumerInfo;
Expand Down Expand Up @@ -88,6 +89,21 @@ public Subscription addConsumer(ConnectionContext context, ConsumerInfo info) th
return subscription;
}

@Override
public void removeConsumer(ConnectionContext context, ConsumerInfo info) throws Exception {
if (ReplicaSupport.isReplicationDestination(info.getDestination()) && brokerService.isUseJmx() &&
replicaPolicy.isHideReplicationDestination()) {
ManagedRegionBroker managedRegionBroker = (ManagedRegionBroker) getAdaptor(ManagedRegionBroker.class);
if (managedRegionBroker != null) {
// Bypassing ManagedRegionBroker to avoid failures in unregisterSubscription
managedRegionBroker.getRegion(info.getDestination()).removeConsumer(context, info);
}
} else {
super.removeConsumer(context, info);
}

}

private void reregisterReplicationDestination(ActiveMQDestination replicationDestination, Destination destination) {
try {
if (!brokerService.isUseJmx()) {
Expand Down

0 comments on commit d4811b7

Please sign in to comment.