CLOUDSTACK-8078: [Automation] Deletion of Affinity Groups - 
CloudRuntimeException: No Event Pubish can be wrapped within DB Transaction!

Changes:
-     The event of deleteing an affinity group is published on the MessageBus 
so that IAM Service can listen and process the event, However the publish 
operation should not be handled within a DB transaction, since it may take 
longer and hold the DB transaction for long unnecessarily
-    Publish any events to MessageBus outside of the transaction


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/74720830
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/74720830
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/74720830

Branch: refs/heads/master
Commit: 74720830cdfa3a376682f43c375e834bdb81052d
Parents: 141a71b
Author: Prachi Damle <prachi.da...@citrix.com>
Authored: Tue Dec 16 16:46:28 2014 -0800
Committer: Prachi Damle <prachi.da...@citrix.com>
Committed: Wed Dec 17 11:43:05 2014 -0800

----------------------------------------------------------------------
 .../apache/cloudstack/affinity/AffinityGroupServiceImpl.java  | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/74720830/server/src/org/apache/cloudstack/affinity/AffinityGroupServiceImpl.java
----------------------------------------------------------------------
diff --git 
a/server/src/org/apache/cloudstack/affinity/AffinityGroupServiceImpl.java 
b/server/src/org/apache/cloudstack/affinity/AffinityGroupServiceImpl.java
index 2139b5d..d25bddb 100644
--- a/server/src/org/apache/cloudstack/affinity/AffinityGroupServiceImpl.java
+++ b/server/src/org/apache/cloudstack/affinity/AffinityGroupServiceImpl.java
@@ -299,13 +299,14 @@ public class AffinityGroupServiceImpl extends ManagerBase 
implements AffinityGro
                     if (groupDomain != null) {
                         _affinityGroupDomainMapDao.remove(groupDomain.getId());
                     }
-                    // remove its related ACL permission
-                    Pair<Class<?>, Long> params = new Pair<Class<?>, 
Long>(AffinityGroup.class, affinityGroupIdFinal);
-                    _messageBus.publish(_name, 
EntityManager.MESSAGE_REMOVE_ENTITY_EVENT, PublishScope.LOCAL, params);
                 }
             }
         });
 
+        // remove its related ACL permission
+        Pair<Class<?>, Long> params = new Pair<Class<?>, 
Long>(AffinityGroup.class, affinityGroupIdFinal);
+        _messageBus.publish(_name, EntityManager.MESSAGE_REMOVE_ENTITY_EVENT, 
PublishScope.LOCAL, params);
+
         if (s_logger.isDebugEnabled()) {
             s_logger.debug("Deleted affinity group id=" + affinityGroupId);
         }

Reply via email to