Confluence 2.2 to Confluence 5.9
Job modules are auto-wired in Confluence 4.0.1 and later.
|Status:||Deprecated in Confluence 5.10 - use Job Config instead|
Job plugin modules enable you to add repeatable tasks to Confluence, which are in turn scheduled by Trigger Module.
- For more information about plugins in general, read Confluence Plugin Guide.
- To learn how to install and configure plugins (including macros), read Installing a Plugin.
- For an introduction to writing your own plugins, read Writing Confluence Plugins
Job Plugin Module
The Job plugin module adds a simple reusable component within a plugin. At a minimum, the module class must implement Quartz's Job interface, but for access to Confluence's objects and database you should extend com.atlassian.quartz.jobs.AbstractJob. Jobs are scheduled with Trigger Module.
In Confluence 4.0.1 and later, Jobs are autowired by Spring (see: CONF-20162 for workarounds in earlier versions).
Here is an example
atlassian-plugin.xml fragment containing a single Job module:
- the name attribute represents how this component will be referred to in the Confluence interface.
- the key attribute represents the internal, system name for your Job. This is what the Trigger will refer to.
- the class attribute represents the class of the Job to be created. The class must have a no-argument constructor, or it will not be able to be instantiated by Confluence.
- the perClusterJob attribute, if "true", indicates that this job will only run once when triggered in a cluster rather than once on every node.
For examples of how to schedule Jobs to be run, see Trigger Module.
Please note that transaction management is not automatically applied when you extend
com.atlassian.quartz.jobs.AbstractJob. The core Confluence services and managers are declaratively wrapped so individual calls to any of these services do not require you to perform explicit transaction management. However, you may need to manually wrap your job execution in a transaction if -
- You are making use of your own components which are not declaratively wrapped in a transaction via Spring configuration.
- You are sharing data between a number of different calls to one or more services
To programmatically wrap in a transaction in your plugin you should first import the SAL transaction template. So in your
atlassian-plugin.xml include -
Import the following classes -
Enable your job to be auto-wired via the constructor and wrap your execution in a transaction as shown -
Do not implement a single transaction which spans the work of a long lived job. This could impact the availability of the Confluence service.
(Discussion on automatic transaction management in jobs can be followed on CONF-35465).