Job Expiry and Removal
By default, processed jobs remain in the database and will continue to be available to download from the Saved Tables tab.
If you wish to automatically remove jobs after a period of time you need to:
- Configure the job expiry time (this specifies that a job will expire a certain period of time after it has been downloaded at least once by the owning users).
- Activate the job removal scheduled task (this runs at your chosen interval and automatically removes any expired jobs from the database).
You need to configure both job expiry and job removal.
Job Expiry
To set the job expiry:
Go to the Tomcat instance that is running SuperWEB2 and open <tomcat_home>\webapps\webapi\WEB-INF\config\data-access-config-jqm.xml in a text editor.
Make a backup copy of this file before making any changes.
Locate the following line:
XML<!-- <property name="globalJobExpiryPeriod" value="7 days" /> -->
Remove the comments:
XML<property name="globalJobExpiryPeriod" value="7 days" />
- Change the value to set the expiry time. The expiry time must be set in days and must include the word day or days. The following are some examples of valid expiry periods: 5 days, 1 day, 0.2 day, 7.3 days
- Save your changes to data-access-config-jqm.xml.
- Restart the instance of Tomcat where you have made changes.
Job Removal
Once you have configured an expiry period, you need to activate the scheduled task to automatically remove expired jobs from the database.
Go to the Tomcat instance that is running Job Queue Manager and open <tomcat_home>\webapps\queuedjobservice\WEB-INF\config\common\service-config.xml in a text editor.
Make a backup copy of this file before making any changes.
Locate the following section:
XML<!-- Un-comment the lines below to enable job expiry. <bean name="expiredJobRemover" class="org.springframework.scheduling.quartz.JobDetailFactoryBean"> <property name="jobClass" value="au.com.str.jobqueue.server.scheduling.ExpiredJobRemoval" /> <property name="jobDataAsMap"> <map> <entry key="entityManagerFactory" value-ref="entityManagerFactory" /> </map> </property> </bean> <bean id="scheduleTrigger" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean"> <property name="jobDetail" ref="expiredJobRemover"/> <!- run every minute: "0 0/1 * * * ?" -> <!- run every morning at 6 AM -> <property name="cronExpression" value="0 0 6 * * ?"/> </bean> <bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean"> <property name="triggers"> <list> <ref bean="scheduleTrigger" /> </list> </property> </bean> -->
Remove the comments from the start and end of this section:
XML<bean name="expiredJobRemover" class="org.springframework.scheduling.quartz.JobDetailFactoryBean"> <property name="jobClass" value="au.com.str.jobqueue.server.scheduling.ExpiredJobRemoval" /> <property name="jobDataAsMap"> <map> <entry key="entityManagerFactory" value-ref="entityManagerFactory" /> </map> </property> </bean> <bean id="scheduleTrigger" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean"> <property name="jobDetail" ref="expiredJobRemover"/> <!- run every minute: "0 0/1 * * * ?" -> <!- run every morning at 6 AM -> <property name="cronExpression" value="0 0 6 * * ?"/> </bean> <bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean"> <property name="triggers"> <list> <ref bean="scheduleTrigger" /> </list> </property> </bean>
Edit the following line to specify when you want the scheduled task to run a cleanup of expired jobs.
XML<property name="cronExpression" value="0 0 6 * * ?"/>
You need to specify the scheduled time in the form of a cron expression. The values represent seconds, minutes, hours, day of month, month, day of week.
Remove the following lines (these are just examples; they need to be removed because once you have removed the comments that enclose the whole section, these lines will not be properly commented out):
XML<!- run every minute: "0 0/1 * * * ?" -> <!- run every morning at 6 AM ->
As an alternative to deleting these lines, if you want to leave them as comments for future reference, you can do this by adding an additional - symbol at the start and end of each line, to make them into valid comments. For example:
XML<!-- run every minute: "0 0/1 * * * ?" --> <!-- run every morning at 6 AM -->
Save your changes to service-config.xml.
- Restart the instance of Tomcat where you have made changes.
If you are running multiple instances of Job Queue Manager against a single Job Queue Manager database, make sure you do not run multiple instances of the job removal task at the same time. This will cause unnecessary concurrent database access and error messages in the log files.
Either:
- Configure the expired job remover on only one of the Job Queue Manager instances; or
- Make sure that each expired job remover has a sufficiently different scheduled trigger time so that they do not run concurrently.