Class DeadLetterQueue

java.lang.Object
com.atlassian.bamboo.grpc.DeadLetterQueue

public class DeadLetterQueue extends Object
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 Details

  • Constructor Details

    • DeadLetterQueue

      public DeadLetterQueue()
    • DeadLetterQueue

      @VisibleForTesting public DeadLetterQueue(int queueSize, int queueScanningIntervalSeconds, int maxRetriesNumber)
  • Method Details

    • getDeadLetterQueueMonitorJob

      @VisibleForTesting protected Runnable getDeadLetterQueueMonitorJob()
    • execute

      public boolean execute(Supplier<Runnable> toWrap, boolean handleByDeadLetterQueue)
      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

      public <T> Pair<Long,Long> executeIfPresent(T item, Consumer<T> consumer, boolean handleByDeadLetterQueue)