Class AutomationQueueImpl
java.lang.Object
com.codebarrel.automation.api.queue.AutomationQueueImpl
- All Implemented Interfaces:
AutomationQueue
-
Constructor Summary
ConstructorsConstructorDescriptionAutomationQueueImpl(AutomationQueueEventPublisher eventPublisher, AutomationQueueStore queueStore) -
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 asAutomationQueue.claimItems(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.longgetCount(Environment env) 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 environment, 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.
-
Constructor Details
-
AutomationQueueImpl
@Inject public AutomationQueueImpl(AutomationQueueEventPublisher eventPublisher, AutomationQueueStore queueStore)
-
-
Method Details
-
addItem
Description copied from interface:AutomationQueueAdds a single item to the queue.- Specified by:
addItemin interfaceAutomationQueue- 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
Description copied from interface:AutomationQueueAdds multiple queue items in bulk to the queue. Listeners will only be notified when all items have been added.- Specified by:
addItemsin interfaceAutomationQueue- Parameters:
environment- The env we are in (prod or dev).items- The queue item to add to the queue.
-
claimItems
Description copied from interface:AutomationQueueClaims 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:
claimItemsin interfaceAutomationQueue- 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
Description copied from interface:AutomationQueueSame asAutomationQueue.claimItems(Environment, String, ClaimLimits)but will only retrieve and return ids which is faster when clamining many items.- Specified by:
claimItemsByIdin interfaceAutomationQueue
-
claimItem
Description copied from interface:AutomationQueueClaims 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:
claimItemin interfaceAutomationQueue- 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
Description copied from interface:AutomationQueueResolves a previously claimed item.- Specified by:
resolveItemin interfaceAutomationQueue- Parameters:
tenantExecution- the execution of this rule.itemId- The id of the item to resolve.- Returns:
- remaining items queued.
-
clearUnresolved
Description copied from interface:AutomationQueueRemoves 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:
clearUnresolvedin interfaceAutomationQueue- 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
Description copied from interface:AutomationQueueReturn current queue stats- Specified by:
getStatisticsin interfaceAutomationQueue- Parameters:
env- The env we are in (prod or dev).- Returns:
- current queue stats
-
getItem
Description copied from interface:AutomationQueueRetrieve an item by its id. May be empty.- Specified by:
getItemin interfaceAutomationQueue- Parameters:
env- The env we are in (prod or dev).itemId- The id of the item to retrieve- Returns:
- the item or empty
-
getItemAndMarkForProcessing
Description copied from interface:AutomationQueueThis will mark the item for processing and only return it if it wasn't already processing.- Specified by:
getItemAndMarkForProcessingin interfaceAutomationQueue- Parameters:
env- The env we are in (prod or dev).itemId- The id of the item to retrieve- Returns:
- the item or empty
-
hasMoreItemsQueued
Description copied from interface:AutomationQueueCheck 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:
hasMoreItemsQueuedin interfaceAutomationQueue- 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
Description copied from interface:AutomationQueueChecks if this rule is already executing with an audit item id other than the current one- Specified by:
isRuleInProgressin interfaceAutomationQueue- Parameters:
context- The tenant to execute this forruleId- The id of the rule- Returns:
- true if the rule is in progress already
-
getCount
- Specified by:
getCountin interfaceAutomationQueue
-