You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by cs...@apache.org on 2019/11/26 16:22:23 UTC

[sling-org-apache-sling-distribution-journal] 01/02: SLING-8861 - Longer delay in error case

This is an automated email from the ASF dual-hosted git repository.

cschneider pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-distribution-journal.git

commit 1c4cbc9ba060d834194529efe2f8a0532a006333
Author: Christian Schneider <cs...@adobe.com>
AuthorDate: Tue Nov 26 17:08:13 2019 +0100

    SLING-8861 - Longer delay in error case
---
 .../journal/impl/queue/impl/PubQueueCache.java          | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/src/main/java/org/apache/sling/distribution/journal/impl/queue/impl/PubQueueCache.java b/src/main/java/org/apache/sling/distribution/journal/impl/queue/impl/PubQueueCache.java
index 5128dc6..438c765 100644
--- a/src/main/java/org/apache/sling/distribution/journal/impl/queue/impl/PubQueueCache.java
+++ b/src/main/java/org/apache/sling/distribution/journal/impl/queue/impl/PubQueueCache.java
@@ -85,6 +85,7 @@ public class PubQueueCache {
      * Interval in millisecond between two seeding messages.
      */
     private static final long SEEDING_DELAY_MS = 1000;
+    private static final long SEEDING_ERROR_DELAY_MS = 10000;
 
     /**
      * Blocks the threads awaiting until the agentQueues
@@ -126,7 +127,6 @@ public class PubQueueCache {
 
     private final Thread seeder;
 
-
     public PubQueueCache(MessagingProvider messagingProvider, EventAdmin eventAdmin, DistributionMetricsService distributionMetricsService, String topic) {
         this.messagingProvider = messagingProvider;
         this.eventAdmin = eventAdmin;
@@ -166,18 +166,23 @@ public class PubQueueCache {
             LOG.debug("Send seeding message");
             try {
                 sender.send(topic, pkgMsg);
+                sleep(SEEDING_DELAY_MS);
             } catch (MessagingException e) {
                 LOG.warn(e.getMessage(), e);
-            }
-            try {
-                Thread.sleep(SEEDING_DELAY_MS);
-            } catch (InterruptedException e) {
-                Thread.currentThread().interrupt();
+                sleep(SEEDING_ERROR_DELAY_MS);
             }
         }
         LOG.info("Stop message seeder");
     }
 
+    private void sleep(long sleepMs) {
+        try {
+            Thread.sleep(sleepMs);
+        } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
+        }
+    }
+
     private PackageMessage createTestMessage() {
         String pkgId = UUID.randomUUID().toString();
         return PackageMessage.newBuilder()