Skip to main content

PollingJobQueueStrategy

PollingJobQueueStrategy

This class allows easier implementation of JobQueueStrategy in a polling style. Instead of providing JobQueueStrategy start() you should provide a next method.

This class should be extended by any strategy which does not support a push-based system to notify on new jobs. It is used by the SqlJobQueueStrategy and InMemoryJobQueueStrategy.

Signature
class PollingJobQueueStrategy extends InjectableJobQueueStrategy {
public concurrency: number;
public pollInterval: number | ((queueName: string) => number);
public setRetries: (queueName: string, job: Job) => number;
public backOffStrategy?: BackoffStrategy;
public gracefulShutdownTimeout: number;
protected activeQueues = new QueueNameProcessStorage<ActiveQueue<any>>();
constructor(config?: PollingJobQueueStrategyConfig)
constructor(concurrency?: number, pollInterval?: number)
constructor(concurrencyOrConfig?: number | PollingJobQueueStrategyConfig, maybePollInterval?: number)
start(queueName: string, process: (job: Job<Data>) => Promise<any>) => ;
stop(queueName: string, process: (job: Job<Data>) => Promise<any>) => ;
cancelJob(jobId: ID) => Promise<Job | undefined>;
next(queueName: string) => Promise<Job | undefined>;
update(job: Job) => Promise<void>;
findOne(id: ID) => Promise<Job | undefined>;
}
  • Extends: InjectableJobQueueStrategy

concurrency

property
number

pollInterval

property
number | ((queueName: string) => number)

setRetries

property
(queueName: string, job: Job) => number

backOffStrategy

gracefulShutdownTimeout

property
number

activeQueues

property

constructor

method
(config?: PollingJobQueueStrategyConfig) => PollingJobQueueStrategy

constructor

method
(concurrency?: number, pollInterval?: number) => PollingJobQueueStrategy

constructor

method
(concurrencyOrConfig?: number | PollingJobQueueStrategyConfig, maybePollInterval?: number) => PollingJobQueueStrategy

start

method
(queueName: string, process: (job: Job<Data>) => Promise<any>) =>

stop

method
(queueName: string, process: (job: Job<Data>) => Promise<any>) =>

cancelJob

method
(jobId: ID) => Promise<Job | undefined>

next

method
(queueName: string) => Promise<Job | undefined>

Should return the next job in the given queue. The implementation is responsible for returning the correct job according to the time of creation.

update

method
(job: Job) => Promise<void>

Update the job details in the store.

findOne

method
(id: ID) => Promise<Job | undefined>

Returns a job by its id.