Package com.atlassian.bamboo.grpc
Class DeadLetterQueue
java.lang.Object
com.atlassian.bamboo.grpc.DeadLetterQueue
This class is responsible for being the combination of dead letter queue and its monitor.
The monitor is launched at the moment of object creation.
Instead of storing in the dead letter queue the whole events, we store actions. Single event could carry multiple actions. This was designed this way to handle partial failures, for example, a plan cache invalidation event carries multiple plan keys, each one of them triggering the invalidation action. If only one of the actions fails, we add this action to the dead letter queue instead of adding the whole event (with all its actions). As a result, we don't process multiple times the actions that have already been successfully processed before.
- Since:
- 9.5
-
Field Summary
Modifier and TypeFieldDescriptionprotected final LinkedBlockingQueue<Pair<Supplier<Runnable>,
Integer>> -
Constructor Summary
ConstructorDescriptionDeadLetterQueue
(int queueSize, int queueScanningIntervalSeconds, int maxRetriesNumber) -
Method Summary
Modifier and TypeMethodDescriptionboolean
Wraps the runnable with try-catch block and returns true if the runnable was executed successfully, otherwise returns false.executeIfPresent
(T item, Consumer<T> consumer, boolean handleByDeadLetterQueue) executeIfPresentOnCollection
(List<T> items, Consumer<T> consumer, boolean handleByDeadLetterQueue) protected Runnable
-
Field Details
-
deadLetterQueue
@VisibleForTesting protected final LinkedBlockingQueue<Pair<Supplier<Runnable>,Integer>> deadLetterQueue
-
-
Constructor Details
-
DeadLetterQueue
public DeadLetterQueue() -
DeadLetterQueue
@VisibleForTesting public DeadLetterQueue(int queueSize, int queueScanningIntervalSeconds, int maxRetriesNumber)
-
-
Method Details
-
getDeadLetterQueueMonitorJob
-
execute
Wraps the runnable with try-catch block and returns true if the runnable was executed successfully, otherwise returns false. -
executeIfPresentOnCollection
public <T> Pair<Long,Long> executeIfPresentOnCollection(List<T> items, Consumer<T> consumer, boolean handleByDeadLetterQueue) - Returns:
- the pair with the first element being the number of successful executions and the second element being the number of failed executions
-
executeIfPresent
-