Details
-
Improvement
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
Description
We already have an event corresponding to the successful distribution of a package [0].
In the Distribution Core impl, this event is (correctly) generated when the package is successfully distributed [1]. However, if the distribution agent has a valid error-strategy associated with it and if the attempts to distribute them exceed a fixed number of retries, the packages are moved silently to error-queue [2].
I propose that this asymmetry be addressed.
Since DistributionEventTopics is a ProviderType, it should be possible to introduce another constant (which queue-processors in Distribution Core, as well as any custom ones) can use to identify failed distribution-requests [3].
Distribution Core can be further enhanced to create this event when it re-enqueues the queue-item that has exceeded its retries in the error-queue [4].
[0] https://github.com/apache/sling-org-apache-sling-distribution-api/blob/ff4c3ae5b7129ba7b1f4f59d35edf93bf6e3d63f/src/main/java/org/apache/sling/distribution/event/DistributionEventTopics.java#L44
[1] https://github.com/apache/sling-org-apache-sling-distribution-core/blob/537bb57af821f21537cf4a24ad7d2347c6a5dae1/src/main/java/org/apache/sling/distribution/agent/impl/SimpleDistributionAgentQueueProcessor.java#L137-L138
[2] https://github.com/apache/sling-org-apache-sling-distribution-core/blob/537bb57af821f21537cf4a24ad7d2347c6a5dae1/src/main/java/org/apache/sling/distribution/agent/impl/SimpleDistributionAgentQueueProcessor.java#L158-L160
[3]
diff --git a/src/main/java/org/apache/sling/distribution/event/DistributionEventTopics.java b/src/main/java/org/apache/sling/distribution/event/DistributionEventTopics.java index 8a75dda..2be0358 100644 --- a/src/main/java/org/apache/sling/distribution/event/DistributionEventTopics.java +++ b/src/main/java/org/apache/sling/distribution/event/DistributionEventTopics.java @@ -43,6 +43,10 @@ public interface DistributionEventTopics { */ String AGENT_PACKAGE_DISTRIBUTED = EVENT_BASE + "/agent/package/distributed"; + /** + * event for package errored-out + */ + String AGENT_PACKAGE_ERRORED = EVENT_BASE + "/agent/package/errored"; /** * event for package imported
[4]
diff --git a/src/main/java/org/apache/sling/distribution/agent/impl/SimpleDistributionAgentQueueProcessor.java b/src/main/java/org/apache/sling/distribution/agent/impl/SimpleDistributionAgentQueueProcessor.java index 1a04fa7..eba47e9 100644 --- a/src/main/java/org/apache/sling/distribution/agent/impl/SimpleDistributionAgentQueueProcessor.java +++ b/src/main/java/org/apache/sling/distribution/agent/impl/SimpleDistributionAgentQueueProcessor.java @@ -157,6 +157,8 @@ class SimpleDistributionAgentQueueProcessor implements DistributionQueueProcesso if (errorQueueStrategy != null && queueItemStatus.getAttempts() > retryAttempts) { removeItemFromQueue = reEnqueuePackage(distributionPackage); + distributionEventFactory.generatePackageEvent(DistributionEventTopics.AGENT_PACKAGE_ERRORED, + DistributionComponentKind.AGENT, agentName, distributionPackage.getInfo()); distributionLog.info("[{}] PACKAGE-QUEUED {}: distribution package {} was enqueued to an error queue", queueName, requestId, distributionPackage.getId()); } }