public abstract class AbstractJobQueue extends Object implements Queue, JobStatusNotifier
JobStatusNotifier.NotifierContext
Modifier and Type | Field and Description |
---|---|
protected InternalQueueConfiguration |
configuration
Configuration.
|
protected boolean |
isWaiting
Is the queue currently waiting(sleeping)
|
protected org.slf4j.Logger |
logger
The logger.
|
protected String |
queueName
The queue name.
|
protected boolean |
running
Are we still running?
|
protected QueueServices |
services
Services used by the queues.
|
CONTEXT_PROPERTY_NAME
Constructor and Description |
---|
AbstractJobQueue(String name,
InternalQueueConfiguration config,
QueueServices services,
Set<String> topics)
Create a new queue
|
Modifier and Type | Method and Description |
---|---|
protected boolean |
canBeClosed()
Check whether this queue can be closed
|
void |
checkForUnprocessedJobs()
Periodically check for started jobs without an acknowledge.
|
void |
clear()
Remove all outstanding jobs from the queue.
|
void |
close()
Close this queue.
|
protected boolean |
executeJob(JobHandler handler)
Execute a job
|
boolean |
finishedJob(org.osgi.service.event.Event job,
boolean shouldReschedule)
Notify that the job is finished.
|
InternalQueueConfiguration |
getConfiguration()
Return the queue configuration
|
String |
getName()
Get the name of the job queue.
|
protected long |
getRetryDelay(JobHandler handler) |
Object |
getState(String key)
For monitoring purposes and possible extensions from the different
queue types.
|
String |
getStateInfo()
Return some information about the current state of the queue.
|
Statistics |
getStatistics()
Return statistics information about this queue.
|
protected void |
ignoreException(Exception e)
Helper method which just logs the exception in debug mode.
|
protected boolean |
isOutdated()
Is the queue outdated?
|
boolean |
isSuspended()
Is the queue currently suspended?
|
protected abstract void |
notifyFinished(boolean reschedule) |
void |
outdate()
Outdate this queue.
|
void |
removeAll()
Remove all outstanding jobs and delete them.
|
protected void |
reschedule(JobHandler handler) |
void |
resume()
Resume a suspended queue.
|
boolean |
sendAcknowledge(org.osgi.service.event.Event job)
Send an acknowledge message that someone is processing the job.
|
void |
start()
Start the job queue.
|
protected abstract void |
start(JobHandler handler)
Start processing of a new job.
|
boolean |
stopJob(JobImpl job) |
void |
suspend()
Suspend the queue - when a queue is suspended it stops processing
jobs - however already started jobs are finished (but not rescheduled).
|
boolean |
tryToClose()
Check if the queue can be closed
|
void |
wakeUpQueue(Set<String> topics)
Inform the queue about a job for the topic
|
protected final org.slf4j.Logger logger
protected final InternalQueueConfiguration configuration
protected volatile String queueName
protected volatile boolean running
protected final QueueServices services
protected volatile boolean isWaiting
public AbstractJobQueue(String name, InternalQueueConfiguration config, QueueServices services, Set<String> topics)
name
- The queue nameconfig
- The queue configurationpublic InternalQueueConfiguration getConfiguration()
getConfiguration
in interface Queue
public String getName()
public Statistics getStatistics()
Queue
getStatistics
in interface Queue
Queue.getStatistics()
public void start()
protected boolean isOutdated()
public void outdate()
public boolean tryToClose()
protected boolean canBeClosed()
public void close()
public void checkForUnprocessedJobs()
public void wakeUpQueue(Set<String> topics)
topic
- A new topic.protected boolean executeJob(JobHandler handler)
public boolean finishedJob(org.osgi.service.event.Event job, boolean shouldReschedule)
JobStatusNotifier
false
indicates an error
during the processing. If the job should be rescheduled, true
indicates
that the job could be rescheduled. If an error occurs or the number of retries is
exceeded, false
will be returned.finishedJob
in interface JobStatusNotifier
job
- The job.shouldReschedule
- Should the event be rescheduled?true
if everything went fine, false
otherwise.JobStatusNotifier.finishedJob(org.osgi.service.event.Event, boolean)
public boolean sendAcknowledge(org.osgi.service.event.Event job)
JobStatusNotifier
sendAcknowledge
in interface JobStatusNotifier
job
- The job.true
if the ack is ok, false
otherwise (e.g. if
someone else already send an ack for this job.JobStatusNotifier.sendAcknowledge(org.osgi.service.event.Event)
public void resume()
Queue
Queue.suspend()
. If the queue is not
suspended, calling this method has no effect.
Depending on the queue implementation, if a job failed a job queue might
sleep for a configured time, before a new job is processed. By calling this
method, the job queue can be woken up and force an immediate reprocessing.
This feature is only supported by ordered queues at the moment. If a queue
does not support this feature, calling this method has only an effect if
the queue is really suspended.resume
in interface Queue
Queue.resume()
public void suspend()
Queue
Queue.resume()
.suspend
in interface Queue
Queue.suspend()
public boolean isSuspended()
Queue
isSuspended
in interface Queue
Queue.isSuspended()
public void removeAll()
Queue
removeAll
in interface Queue
Queue.removeAll()
public void clear()
Queue
clear
in interface Queue
Queue.clear()
public Object getState(String key)
Queue
getState
in interface Queue
Queue.getState(java.lang.String)
public String getStateInfo()
Queue
getStateInfo
in interface Queue
Queue.getStateInfo()
protected long getRetryDelay(JobHandler handler)
protected void reschedule(JobHandler handler)
protected void ignoreException(Exception e)
e
- public boolean stopJob(JobImpl job)
protected abstract void start(JobHandler handler)
handler
- The new job handlerprotected abstract void notifyFinished(boolean reschedule)
Copyright © 2007–2014 The Apache Software Foundation. All rights reserved.