jbertram 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_r298601831
 
 

 ##########
 File path: 
artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/AddressControlImpl.java
 ##########
 @@ -373,6 +372,86 @@ public String sendMessage(final Map<String, String> 
headers,
       return MBeanInfoHelper.getMBeanAttributesInfo(AddressControl.class);
    }
 
+   @Override
+   public void pause() throws Exception {
+      pause(false);
+   }
+
+   @Override
+   public void pause(boolean persist) throws Exception {
+      if (AuditLogger.isEnabled()) {
+         AuditLogger.pause(addressInfo);
+      }
+      checkStarted();
+
+      clearIO();
+      try {
+         if (!addressInfo.isPaused()) {
+            addressInfo.pause();
+            if (persist) {
+               
server.getStorageManager().storeAddressStatus(addressInfo.getId(), 
AddressStatus.PAUSED);
+            }
+            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());
+                     if (coreQueueControl != null) {
+                        coreQueueControl.pause();
+                     }
+                  }
+               }
+            }
+         }
+      } finally {
+         blockOnIO();
+      }
+   }
+
+   @Override
+   public void resume() throws Exception {
+      resume(false);
+   }
+
+   @Override
+   public void resume(boolean persist) throws Exception {
+      if (AuditLogger.isEnabled()) {
+         AuditLogger.resume(addressInfo);
+      }
+      checkStarted();
+
+      clearIO();
+      try {
+         if (addressInfo.isPaused()) {
+            addressInfo.resume();
+            if (persist) {
+               
server.getStorageManager().storeAddressStatus(addressInfo.getId(), 
AddressStatus.RUNNING);
 
 Review comment:
   Yes. That appears to be the most straight-forward solution.

----------------------------------------------------------------
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