brusdev commented on a change in pull request #2731: [ARTEMIS-2401]: Implement 
the Pause method for a Topic
URL: https://github.com/apache/activemq-artemis/pull/2731#discussion_r297486077
 
 

 ##########
 File path: 
artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/AddressControlImpl.java
 ##########
 @@ -373,6 +371,58 @@ public String sendMessage(final Map<String, String> 
headers,
       return MBeanInfoHelper.getMBeanAttributesInfo(AddressControl.class);
    }
 
+   @Override
+   public void pauseConsumers() throws Exception {
+      if (AuditLogger.isEnabled()) {
+         AuditLogger.pause(addressInfo);
+      }
+      checkStarted();
+
+      clearIO();
+      try {
+         if (!addressInfo.isPaused()) {
+            addressInfo.pauseConsumers();
+            Bindings bindings = 
server.getPostOffice().lookupBindingsForAddress(addressInfo.getName());
+            if (bindings != null) {
+               for (Binding binding : bindings.getBindings()) {
+                  if (binding instanceof QueueBinding) {
+                     QueueControl coreQueueControl = (QueueControl) 
managementService.getResource(ResourceNames.QUEUE + 
binding.getUniqueName().toString());
+                     coreQueueControl.pause();
 
 Review comment:
   I have a little concern here and in resumeConsumers. In a case with many 
bindings one of related queues could be deleted during the iteration and 
coreQueueControl could be null. Adding a check on coreQueueControl before to 
call coreQueueControl.pause should avoid to interrupt the iteration for a 
NullPointerException.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to