Interface AutomationQueue
- All Known Implementing Classes:
AutomationQueueImpl
public interface AutomationQueue
Provides a tenant aware queue that is used to execute automation rules ordered by priority and insertion order
with limits overall and per tenant that can be claimed for execution.
-
Method Summary
Modifier and TypeMethodDescriptionlongaddItem(Environment env, QueueItemBean item) Adds a single item to the queue.voidaddItems(Environment environment, List<QueueItemBean> items) Adds multiple queue items in bulk to the queue.claimItem(Environment env, String claimant, ClaimLimits limits) Claims a single item for execution from the queue up the the limits specified.claimItems(Environment env, String claimant, ClaimLimits limits) Claims multiple items for execution from the queue up the the limits specified.claimItemsById(Environment env, String claimant, ClaimLimits limits) Same asclaimItems(Environment, String, ClaimLimits)but will only retrieve and return ids which is faster when clamining many items.voidclearUnresolved(Environment env, Date olderThan) Removes any items from the queue that were claimed older than a certain date.getAutomationQueueInsightByEventType(int limit) Gets the automation queue insight with events grouped by event type.getAutomationQueueInsightByRule(int limit) Gets the automation queue insight with events grouped by rule.longgetCount(Environment env) longRetrieves the earliest created time of an unprocessed item in the queue.getItem(Environment env, long itemId) Retrieve an item by its id.getItemAndMarkForProcessing(Environment env, long itemId) This will mark the item for processing and only return it if it wasn't already processing.getStatistics(Environment env) Return current queue statsbooleanhasMoreItemsQueued(Environment env, long auditItemId) Check if a particular audit item has more items queue up for execution.booleanisRuleInProgress(TenantContext context, long ruleId) Checks if this rule is already executing with an audit item id other than the current onelongresolveItem(TenantExecution tenantExecution, long itemId) Resolves a previously claimed item.
-
Method Details
-
addItem
Adds a single item to the queue.- 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
Adds multiple queue items in bulk to the queue. Listeners will only be notified when all items have been added.- Parameters:
environment- The env we are in (prod or dev).items- The queue item to add to the queue.
-
claimItems
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.- Parameters:
env- The env we are in (prod or dev).claimant- The name of the claimant executing the ruleslimits- queue limits that specify how many items can be claimed.- Returns:
- list of items to execute
-
claimItemsById
Same asclaimItems(Environment, String, ClaimLimits)but will only retrieve and return ids which is faster when clamining many items. -
claimItem
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.- Parameters:
env- The env we are in (prod or dev).claimant- The name of the claimant executing the ruleslimits- queue limits that specify how many items can be claimed.- Returns:
- item to execute
-
resolveItem
Resolves a previously claimed item.- Parameters:
tenantExecution- the execution of this rule.itemId- The id of the item to resolve.- Returns:
- remaining items queued.
-
clearUnresolved
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.- 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
Return current queue stats- Parameters:
env- The env we are in (prod or dev).- Returns:
- current queue stats
-
getItem
Retrieve an item by its id. May be empty.- Parameters:
env- The env we are in (prod or dev).itemId- The id of the item to retrieve- Returns:
- the item or empty
-
getItemAndMarkForProcessing
This will mark the item for processing and only return it if it wasn't already processing.- Parameters:
env- The env we are in (prod or dev).itemId- The id of the item to retrieve- Returns:
- the item or empty
-
hasMoreItemsQueued
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.- Parameters:
env- 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
Checks if this rule is already executing with an audit item id other than the current one- Parameters:
context- The tenant to execute this forruleId- The id of the rule- Returns:
- true if the rule is in progress already
-
getCount
-
getEarliestUnprocessedItemCreatedTime
long getEarliestUnprocessedItemCreatedTime()Retrieves the earliest created time of an unprocessed item in the queue.- Returns:
- the earliest created time of an unprocessed item, or -1 if no unprocessed items are present.
-
getAutomationQueueInsightByEventType
Gets the automation queue insight with events grouped by event type.- Parameters:
limit- the number of groups to return- Returns:
- the automation queue insight
-
getAutomationQueueInsightByRule
Gets the automation queue insight with events grouped by rule.- Parameters:
limit- the number of groups to return- Returns:
- the automation queue insight
-