Package lumis.portal.processqueue
Class QueueManager
- java.lang.Object
-
- lumis.portal.processqueue.QueueManager
-
- All Implemented Interfaces:
IProcessQueueManager
,IProcessQueueManagerSPI
public class QueueManager extends java.lang.Object implements IProcessQueueManagerSPI
Manager that executes all interactions with the process queue. ImplementsIProcessQueueManager
to execute producing related activities andIProcessQueueManagerSPI
to execute consuming related activities.- Since:
- 6.1.0
- Version:
- $Revision$ $Date$
-
-
Constructor Summary
Constructors Constructor Description QueueManager()
Default constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
existsTaskWithLockNotRunning(java.lang.String lockId)
Check if exists a task with given lock identifier that is not running.IQueueTaskProcess
getNextQueueTaskProcessForExecution()
Returns the next task process for execution.IQueueStatistics
getQueueStatistics()
Retrieves the current situation statistics of the queue.IQueueTaskProcess
getTaskProcess(java.lang.String processId)
Retrieves the queue item of represented by the processId.java.util.Collection<IQueueTaskProcess>
getTaskProcessByOwnerId(java.lang.String ownerId)
Returns the processes of a given owner.boolean
isActive()
Indicates if this queue manager is active for processing queued tasks.void
removeFromQueue(IQueueTaskProcess item, boolean notifyListeners)
Removes from queue the current item.void
reprocess(java.lang.String processId)
Triggers the process to be retried.IQueueTaskProcess
schedule(IQueueTask task, QueueTaskScheduleConfig taskScheduleConfig)
Schedules the execution of the given task.void
setFailedStatus(IQueueTaskProcess queueItem)
Sets the given process the status ofQueueTaskProcessStatus.Failed
.
-
-
-
Method Detail
-
schedule
public IQueueTaskProcess schedule(IQueueTask task, QueueTaskScheduleConfig taskScheduleConfig) throws PortalException
Description copied from interface:IProcessQueueManager
Schedules the execution of the given task.This operation uses the current transactional context. The task will only be available for execution after the transaction is commited. If the transaction is rolled back the scheduling will also be aborted.
- Specified by:
schedule
in interfaceIProcessQueueManager
- Parameters:
task
- the task to be executed.taskScheduleConfig
- contains the configuration for the execution schedule.- Returns:
- the scheduled process for that task.
- Throws:
PortalException
- if the task could not be scheduled.
-
getTaskProcess
public IQueueTaskProcess getTaskProcess(java.lang.String processId) throws PortalException
Description copied from interface:IProcessQueueManager
Retrieves the queue item of represented by the processId.- Specified by:
getTaskProcess
in interfaceIProcessQueueManager
- Returns:
- the queue item
- Throws:
PortalException
-
isActive
public boolean isActive()
Description copied from interface:IProcessQueueManager
Indicates if this queue manager is active for processing queued tasks. This method may be polled by tasks to check if queue manager is no longer active, which means it is being shutdown and the task should complete its execution as soon as possible (which may mean to create another task to continue its work later in long duration task scenarios).- Specified by:
isActive
in interfaceIProcessQueueManager
- Returns:
true
if this queue manager is active for processing queue items orfalse
if it is not taking items to be processed and tasks currently executing should complete as soon as possible.
-
getNextQueueTaskProcessForExecution
public IQueueTaskProcess getNextQueueTaskProcessForExecution() throws PortalException, java.lang.InterruptedException
Description copied from interface:IProcessQueueManagerSPI
Returns the next task process for execution. This method waits until there is a task process available.The returned task will already have its status changed to
QueueTaskProcessStatus.Running
.- Specified by:
getNextQueueTaskProcessForExecution
in interfaceIProcessQueueManagerSPI
- Returns:
- the task process.
- Throws:
PortalException
- if there is an error obtaining the process.java.lang.InterruptedException
- if the current thread is interrupted or ifprocess queue became inactive
.
-
removeFromQueue
public void removeFromQueue(IQueueTaskProcess item, boolean notifyListeners) throws PortalException
Description copied from interface:IProcessQueueManagerSPI
Removes from queue the current item.- Specified by:
removeFromQueue
in interfaceIProcessQueueManagerSPI
- Parameters:
item
- to be removed from queue.notifyListeners
- if the threads should be waken up.- Throws:
PortalException
-
setFailedStatus
public void setFailedStatus(IQueueTaskProcess queueItem) throws PortalException
Description copied from interface:IProcessQueueManagerSPI
Sets the given process the status ofQueueTaskProcessStatus.Failed
.- Specified by:
setFailedStatus
in interfaceIProcessQueueManagerSPI
- Parameters:
queueItem
- item to be put in failed status.- Throws:
PortalException
-
getQueueStatistics
public IQueueStatistics getQueueStatistics() throws PortalException
Description copied from interface:IProcessQueueManager
Retrieves the current situation statistics of the queue.- Specified by:
getQueueStatistics
in interfaceIProcessQueueManager
- Returns:
- statistics.
- Throws:
PortalException
-
reprocess
public void reprocess(java.lang.String processId) throws PortalException
Description copied from interface:IProcessQueueManager
Triggers the process to be retried.- Specified by:
reprocess
in interfaceIProcessQueueManager
- Parameters:
processId
- id of the process to be reprocessed.- Throws:
PortalException
-
getTaskProcessByOwnerId
public java.util.Collection<IQueueTaskProcess> getTaskProcessByOwnerId(java.lang.String ownerId) throws PortalException
Description copied from interface:IProcessQueueManager
Returns the processes of a given owner.- Specified by:
getTaskProcessByOwnerId
in interfaceIProcessQueueManager
- Parameters:
ownerId
- the owner identifier.- Returns:
- a collection with the processes.
- Throws:
PortalException
-
existsTaskWithLockNotRunning
public boolean existsTaskWithLockNotRunning(java.lang.String lockId)
Description copied from interface:IProcessQueueManagerSPI
Check if exists a task with given lock identifier that is not running.- Specified by:
existsTaskWithLockNotRunning
in interfaceIProcessQueueManagerSPI
- Parameters:
lockId
- the lock identifier.- Returns:
- true if exists a task with given lock identifier that is not running.
-
-