Class JobConfigModuleDescriptor
- All Implemented Interfaces:
com.atlassian.plugin.ModuleDescriptor<Void>
,com.atlassian.plugin.Resourced
,com.atlassian.plugin.ScopeAware
,com.atlassian.plugin.StateAware
JobConfig
within a plugin.
In atlassian-plugin.xml:
<job-config name="My job" key="myJobId">
<job key="myJobRunner" perClusterJob="true" clusteredOnly="true"/>
<schedule cron-expression="0 * * * * ?" jitterSecs="10"/>
<managed editable="true" keepingHistory="true" canRunAdhoc="true" canDisable="true" disabledByDefault="true"/>
</job-config>
If using spring-scanner, ensure your job runner is defined as a spring bean with a
@org.springframework.stereotype.Component
or @javax.inject.Named
annotation:
@Component
public class MyJobRunner implements JobRunner {
...
}
If not using spring-scanner, then declare your component in atlassian-plugin.xml:
<component key="myJobRunner" class="my.plugin.MyJobRunner"/>
Job runner classes must implement JobRunner
.
schedule
can be interval. This example repeats every hour
(3600000 milliseconds) and only 5 times:
<schedule repeat-interval="3600000" repeat-count="5" />
To repeat indefinitely, set repeat-count
to -1
, or omit it.
repeat-count="0"
means the job runs only once.
job-config
:
name
— represents how this job config will be referred to in the Confluence interface.key
— represents the internal, system name for the job.
job
:
key
- points to theJobRunner
component.perClusterJob
-true
indicates this job will only run once in a cluster rather than on every node.clusteredOnly
- optional,true
indicates this job won't be scheduled in non-clustered environment.
schedule
:
- Either
cron-expression
orrepeat-interval
must present.repeat-count
is optional in case ofrepeat-interval
. jitterSecs
- optional, allows us to introduce some random jitter, this is only for On Demand environment use, to prevent many 1000s of servers from attempting to do similar things all at once, by providing a jitter value less than the size of the schedule frequency we spread the load caused by a process over time.
managed
is optional, if omitted the job will not appear in the
Scheduled Jobs administration page.
If any of these attributes are omitted, their values are assumed to be false
:
editable
— iftrue
, the job's schedule can be edited, forced to false if schedule type is interval.keepingHistory
— iftrue
, the job's history persists and survives server restarts; iffalse
, the job's history is only stored in memory and will be lost upon the next server restart.canRunAdhoc
— iftrue
, the job can be executed manually on the Scheduled Jobs administration screen.canDisable
— iftrue
, the job can be enabled/disabled on the Scheduled Jobs administration screen.disabledByDefault
— iftrue
, the job is disabled by default on the Scheduled Jobs administration screen.
Migration from <job>
TriggerModuleDescriptor
and <trigger>
(JobModuleDescriptor
):
-
For ease of use (see CONF-20162), there's nothing to replace
<job>
. Use<component>
as above instead. -
The XML of
<job-config>
is made to look similar to that of<trigger>
, to make the migration from it easier. -
For managed jobs, the
key
of<job-config>
is used to lookup i18n job name (scheduledjob.desc.<key>
), to display at the Confluence admin UI. Before, it's thekey
of<job>
.
- Since:
- 5.10.3
-
Field Summary
Fields inherited from class com.atlassian.plugin.descriptors.AbstractModuleDescriptor
key, moduleClass, moduleClassName, moduleFactory, name, plugin, resources
-
Constructor Summary
ConstructorDescriptionJobConfigModuleDescriptor
(com.atlassian.plugin.module.ModuleFactory moduleFactory, ManagedScheduledJobRegistrationService jobRegistrationService, com.atlassian.sal.api.timezone.TimeZoneManager timeZoneManager, ClusterManager clusterManager, com.atlassian.scheduler.SchedulerService schedulerService, com.atlassian.event.api.EventListenerRegistrar eventListenerRegistrar, com.atlassian.sal.api.lifecycle.LifecycleManager lifecycleManager, org.osgi.framework.BundleContext bundleContext) -
Method Summary
Modifier and TypeMethodDescriptionvoid
disabled()
void
enabled()
Plugins with unmanaged jobs must wait till application is started before being scheduled.void
init
(@NonNull com.atlassian.plugin.Plugin plugin, @NonNull com.atlassian.plugin.module.Element element) void
void
Do not use TenantArrivedEvent because it's fired before the DB migration Jobs may depend on DB prepared by the DB migration, see PluginFrameworkContextListenerMethods inherited from class com.atlassian.plugin.descriptors.AbstractModuleDescriptor
assertModuleClassImplements, checkPermissions, destroy, equals, getCompleteKey, getDescription, getDescriptionKey, getI18nNameKey, getKey, getMinJavaVersion, getModuleClass, getModuleClassName, getName, getParams, getPlugin, getPluginKey, getRequiredPermissions, getResourceDescriptor, getResourceDescriptors, getResourceLocation, getScopeKey, hashCode, isBroken, isEnabled, isEnabledByDefault, isSystemModule, loadClass, satisfiesMinJavaVersion, setBroken, setPlugin, toString, validate
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.atlassian.plugin.ModuleDescriptor
getDisplayName
-
Constructor Details
-
JobConfigModuleDescriptor
@Autowired public JobConfigModuleDescriptor(com.atlassian.plugin.module.ModuleFactory moduleFactory, ManagedScheduledJobRegistrationService jobRegistrationService, com.atlassian.sal.api.timezone.TimeZoneManager timeZoneManager, ClusterManager clusterManager, com.atlassian.scheduler.SchedulerService schedulerService, com.atlassian.event.api.EventListenerRegistrar eventListenerRegistrar, com.atlassian.sal.api.lifecycle.LifecycleManager lifecycleManager, org.osgi.framework.BundleContext bundleContext)
-
-
Method Details
-
listenApplicationStartedEvent
@PostConstruct public void listenApplicationStartedEvent() -
getModule
-
init
public void init(@NonNull com.atlassian.plugin.Plugin plugin, @NonNull com.atlassian.plugin.module.Element element) throws com.atlassian.plugin.PluginParseException -
onApplicationStartedEvent
Do not use TenantArrivedEvent because it's fired before the DB migration Jobs may depend on DB prepared by the DB migration, see PluginFrameworkContextListener -
enabled
public void enabled()Plugins with unmanaged jobs must wait till application is started before being scheduled. See
onApplicationStartedEvent(ApplicationStartedEvent)
Additionally, managed jobs of plugins enabled at startup, must be registered immediately, otherwise the SchedulerService may malfunction, cause unknown.
- Specified by:
enabled
in interfacecom.atlassian.plugin.StateAware
- Overrides:
enabled
in classcom.atlassian.plugin.descriptors.AbstractModuleDescriptor<Void>
-
disabled
public void disabled()- Specified by:
disabled
in interfacecom.atlassian.plugin.StateAware
- Overrides:
disabled
in classcom.atlassian.plugin.descriptors.AbstractModuleDescriptor<Void>
-