From 485794202c55ffebda35ec69c7c2c0909b3b0f13 Mon Sep 17 00:00:00 2001 From: Alan Davis Date: Tue, 23 Sep 2014 16:10:59 +0000 Subject: [PATCH] ACE-2780: Merged HEAD-BUG-FIX (5.0/Cloud) to HEAD (5.0/Cloud) 85506: Merged DEV to HEAD-BUG-FIX (5.0/Cloud) 85436 : ACE-2780 : TestActivities test never ends - Change transaction handling for multi-threaded feed generation. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@85532 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../alfresco/rest/api/tests/RepoService.java | 34 ++++++++++++++++--- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/source/test-java/org/alfresco/rest/api/tests/RepoService.java b/source/test-java/org/alfresco/rest/api/tests/RepoService.java index 1fbe0da98a..a16d927020 100644 --- a/source/test-java/org/alfresco/rest/api/tests/RepoService.java +++ b/source/test-java/org/alfresco/rest/api/tests/RepoService.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2012 Alfresco Software Limited. + * Copyright (C) 2005-2014 Alfresco Software Limited. * * This file is part of Alfresco * @@ -65,6 +65,8 @@ import org.alfresco.repo.tenant.TenantAdminService; import org.alfresco.repo.tenant.TenantService; import org.alfresco.repo.tenant.TenantUtil; import org.alfresco.repo.tenant.TenantUtil.TenantRunAsWork; +import org.alfresco.repo.transaction.RetryingTransactionHelper; +import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; import org.alfresco.repo.version.VersionModel; import org.alfresco.rest.api.Activities; import org.alfresco.rest.api.impl.node.ratings.RatingScheme; @@ -195,6 +197,7 @@ public class RepoService protected HiddenAspect hiddenAspect; protected NetworksService networksService; protected NamespaceService namespaceService; + protected RetryingTransactionHelper transactionHelper; protected Activities activities; @@ -252,6 +255,7 @@ public class RepoService this.hiddenAspect = (HiddenAspect)applicationContext.getBean("hiddenAspect"); this.networksService = (NetworksService)applicationContext.getBean("networksService"); this.namespaceService = (NamespaceService)applicationContext.getBean("namespaceService"); + this.transactionHelper = (RetryingTransactionHelper)applicationContext.getBean("retryingTransactionHelper"); Scheduler scheduler = (Scheduler)applicationContext.getBean("schedulerFactory"); @@ -784,17 +788,39 @@ public class RepoService public void generateFeed() throws JobExecutionException, SQLException { // process all outstanding activity posts - postLookup.execute(); + transactionHelper.doInTransaction(new RetryingTransactionCallback() + { + @Override + public Void execute() throws Throwable + { + postLookup.execute(); + return null; + } + }, false, true); - Long maxSequence = postDAO.getMaxActivitySeq(); + Long maxSequence = getMaxActivitySeq(); while(maxSequence != null) { feedGenerator.execute(); - maxSequence = postDAO.getMaxActivitySeq(); + maxSequence = getMaxActivitySeq(); } } + private Long getMaxActivitySeq() throws SQLException + { + Long maxSequence = transactionHelper.doInTransaction(new RetryingTransactionCallback() + { + @Override + public Long execute() throws Throwable + { + return postDAO.getMaxActivitySeq(); + } + }, true, true); + + return maxSequence; + } + public Tag addTag(NodeRef nodeRef, String tag) { NodeRef tagNodeRef = taggingService.addTag(nodeRef, tag);