Class AutomationQueueImpl

java.lang.Object
com.codebarrel.automation.api.queue.AutomationQueueImpl
All Implemented Interfaces:
AutomationQueue

public class AutomationQueueImpl extends Object implements AutomationQueue
  • Constructor Details

  • Method Details

    • addItem

      public long addItem(Environment env, QueueItemBean item)
      Description copied from interface: AutomationQueue
      Adds a single item to the queue.
      Specified by:
      addItem in interface AutomationQueue
      Parameters:
      env - The env we are in (prod or dev).
      item - The queue item to add to the queue.
      Returns:
      the id of the item inserted
    • addItems

      public void addItems(Environment environment, List<QueueItemBean> items)
      Description copied from interface: AutomationQueue
      Adds multiple queue items in bulk to the queue. Listeners will only be notified when all items have been added.
      Specified by:
      addItems in interface AutomationQueue
      Parameters:
      environment - The env we are in (prod or dev).
      items - The queue item to add to the queue.
    • claimItems

      public List<QueueItemBean> claimItems(Environment env, String claimant, ClaimLimits limits)
      Description copied from interface: AutomationQueue
      Claims multiple items for execution from the queue up the the limits specified. May return an empty list if the queue is empty or limits have been reached.
      Specified by:
      claimItems in interface AutomationQueue
      Parameters:
      env - The env we are in (prod or dev).
      claimant - The name of the claimant executing the rules
      limits - queue limits that specify how many items can be claimed.
      Returns:
      list of items to execute
    • claimItemsById

      public List<Long> claimItemsById(Environment env, String claimant, ClaimLimits limits)
      Description copied from interface: AutomationQueue
      Same as AutomationQueue.claimItems(Environment, String, ClaimLimits) but will only retrieve and return ids which is faster when clamining many items.
      Specified by:
      claimItemsById in interface AutomationQueue
    • claimItem

      public Optional<QueueItemBean> claimItem(Environment env, String claimant, ClaimLimits limits)
      Description copied from interface: AutomationQueue
      Claims a single item for execution from the queue up the the limits specified. May return empty if the queue is empty or limits have been reached.
      Specified by:
      claimItem in interface AutomationQueue
      Parameters:
      env - The env we are in (prod or dev).
      claimant - The name of the claimant executing the rules
      limits - queue limits that specify how many items can be claimed.
      Returns:
      item to execute
    • resolveItem

      public long resolveItem(TenantExecution tenantExecution, long itemId)
      Description copied from interface: AutomationQueue
      Resolves a previously claimed item.
      Specified by:
      resolveItem in interface AutomationQueue
      Parameters:
      tenantExecution - the execution of this rule.
      itemId - The id of the item to resolve.
      Returns:
      remaining items queued.
    • clearUnresolved

      public void clearUnresolved(Environment env, Date olderThan)
      Description copied from interface: AutomationQueue
      Removes any items from the queue that were claimed older than a certain date. This can be used to remove stuck items from the queue.
      Specified by:
      clearUnresolved in interface AutomationQueue
      Parameters:
      env - The env we are in (prod or dev).
      olderThan - Any items older than this date will be removed (based on claim time)
    • getStatistics

      public QueueStatistics getStatistics(Environment env)
      Description copied from interface: AutomationQueue
      Return current queue stats
      Specified by:
      getStatistics in interface AutomationQueue
      Parameters:
      env - The env we are in (prod or dev).
      Returns:
      current queue stats
    • getItem

      public Optional<QueueItemBean> getItem(Environment env, long itemId)
      Description copied from interface: AutomationQueue
      Retrieve an item by its id. May be empty.
      Specified by:
      getItem in interface AutomationQueue
      Parameters:
      env - The env we are in (prod or dev).
      itemId - The id of the item to retrieve
      Returns:
      the item or empty
    • getItemAndMarkForProcessing

      public Optional<QueueItemBean> getItemAndMarkForProcessing(Environment env, long itemId)
      Description copied from interface: AutomationQueue
      This will mark the item for processing and only return it if it wasn't already processing.
      Specified by:
      getItemAndMarkForProcessing in interface AutomationQueue
      Parameters:
      env - The env we are in (prod or dev).
      itemId - The id of the item to retrieve
      Returns:
      the item or empty
    • hasMoreItemsQueued

      public boolean hasMoreItemsQueued(Environment environment, long auditItemId)
      Description copied from interface: AutomationQueue
      Check if a particular audit item has more items queue up for execution. This can be used to check if a rule execution has finished.
      Specified by:
      hasMoreItemsQueued in interface AutomationQueue
      Parameters:
      environment - The env we are in (prod or dev).
      auditItemId - The id of the audit item
      Returns:
      true if there's more unclaimed items in the queue for an audit item
    • isRuleInProgress

      public boolean isRuleInProgress(TenantContext context, long ruleId)
      Description copied from interface: AutomationQueue
      Checks if this rule is already executing with an audit item id other than the current one
      Specified by:
      isRuleInProgress in interface AutomationQueue
      Parameters:
      context - The tenant to execute this for
      ruleId - The id of the rule
      Returns:
      true if the rule is in progress already
    • getCount

      public long getCount(Environment env)
      Specified by:
      getCount in interface AutomationQueue