Background Jobs

Qualified Name Type

apoc.periodic.list

apoc.periodic.list - list all jobs

Procedure

apoc.periodic.submit

apoc.periodic.submit('name',statement,params) - submit a one-off background statement; parameter 'params' is optional and can contain query parameters for Cypher statement

Procedure

apoc.periodic.countdown

apoc.periodic.countdown('name',statement,repeat-rate-in-seconds) submit a repeatedly-called background statement until it returns 0

Procedure

  • There are also static methods Jobs.submit, and Jobs.schedule, which can be used from other procedures.

  • The jobs list is checked / cleared every 10s for finished jobs.

Many procedures run in the background or asynchronously. The following setting overrides the default thread pool size (processors*2):

apoc.jobs.pool.num_threads=10

Many periodic procedures rely on a scheduled executor that has a pool of threads with a default fixed size (processors/4, at least 1). To configure the pool size, use the following configuration property:

apoc.jobs.scheduled.num_threads=10

This statement repeats until the termination is reached. The statement must return a numeric value and it should decrement (similar to a monotonically decreasing function). When the return value reaches 0 the iteration stops.

For example, to define a counter with a numeric property, use the following command:

CREATE (counter:Counter) SET counter.c = 10

To decrement this property by 1 each second, use the following command:

CALL apoc.periodic.countdown('decrement',"MATCH (counter:Counter) SET counter.c = counter.c - 1 RETURN counter.c as count", 1)