Jobs Module

This XQuery Module provides functions for organizing scheduled, queued, running and cached jobs. Jobs can be commands, queries, client or HTTP requests.

=Conventions=

All functions in this module are assigned to the  namespace, which is statically bound to the jobs prefix. Errors will be bound to the same prefix.

=Services=

A job can be registered as service by supplying the service option to $$:

 (: register job as service; will be run every day at 1 am :) jobs:eval('db:drop("tmp")',, map { 'id':'cleanup', 'start':'01:00:00', 'interval':'P1D', 'service': true }),

(: list registered services :) jobs:services, (: result: db:drop("tmp") :)

(: unregister job :) jobs:stop('cleanup', map { 'service': true })

Some more notes:


 * All job services will be scheduled for evaluation when the BaseX server or BaseX HTTP server is started.
 * If a job service is outdated (e.g. because a supplied end time has been exceeded), it will be removed from the jobs file at startup time.
 * Job services can be updated: If a new job is registered, and if there is already a job with the same id, the old entry will be replaced.
 * The job definitions are stored in a jobs.xml file in the database directory. It can also be edited manually.

=Basic Functions=

jobs:services
=Execution=

There are cases in which a client does not, or cannot, wait until a request is fully processed. The client may be a browser, which sends an HTTP request to the server in order to start another time-consuming query job. The functions in this section allow you to register a new query job from a running query. Jobs can be executed immediately (i.e., as soon as the Concurrency Control allows it) or scheduled for repeated execution. Each registered job gets a job id, and the id can be used to retrieve a query result, stop a job, or wait for its termination.

jobs:wait
=Errors=

=Changelog=


 * Version 9.2


 * Deleted: jobs:invoke (merged with jobs:eval)


 * Version 9.1


 * Updated: $$: registration time added.


 * Version 9.0


 * Added: $$, Services


 * Version 8.6


 * Updated: jobs:eval:  option added.

The module was introduced with Version 8.5.