Spring timed Task QuartzBackground introductionUsing spring to do projects, you need to complete a series of task actions regularly, execute the corresponding code logic, using Spring's quartz component can complete the function of the timed task, the author strongly recommends using Quartz 2.x version.The principle is as follows:I. Introduction to the EnvironmentIde:eclipsejdk:1.8maven:3.5Second, the const
The process of configuring Quartz in spring:
1. Import Jar Package
The jar package that quartz needs is already contained in spring, located under the \lib\quartz of the spring uncompressed directory, Quartz-all-1.6.1.jar,
Copy it to the web-inf/lib of the project.
2. Configure Web.xml to load
If the scheduled task information is logged with memory, the scheduled task information is lost after the app restarts. For example, user A through the system Setup 1 hours after the z operation, set up, because the system restarts, the newly-launched system will be lost "1 hours after the z operation" of the scheduled task. If we need to keep the scheduled task information after the system restarts unexpectedly (or unexpectedly), you can use the database to store the scheduled task information.
Project use:spring+springmvc+jpa+maven1. referencing in Pom.xml Quartz of the Jar PackageQuartz need Spring-context-support-3.2.4.release.jar etc (quartz2.x version required spring3.1 above version support, specific please Baidu)2. Task class (does not inherit the job interface)Package Com.test.utils.quartz;import Java.io.ioexception;import Java.io.inputstream;import java.util.Properties; Import javax.annotation.resource;import com.test.service.order.
Test process:First write a simple task class, test the configuration of the Quartz whether the function (the ultimate goal is to achieve the scheduled deletion of temporary storage folder).The configuration files added in spring are as follows:timed Task quartz (Spring internal integration) - task class for periodically emptying temporary folders - BeanID= "Taskjob"class= "Cn.itcast.oa.util.TaskJob">B
Resolves a problem where the quartz timed task was triggered two times:Where autodeploy= "false" deployonstartup= "false" to prevent the Quartz timer task from being triggered two times by booting from the Tomcat server. (Of course, it can be modified according to requirements, after all, the requirements of each project are different.) )1. The Autodeploy property value is set to False, if this is set to Tr
graphics contexts represents a drawing destination. It contains drawing parameters and all device-related information, which is required when the drawing system executes the drawing command. Graphics contexts defines basic drawing attributes, such as the color, clipping area, line width, style information, font information, compositing options, and others. you can use quartz context to create a function or IOS uikit framework to obtain a graphics co
to stop it . This was very likely to create a memory leak. StackTraceof Thread:java. lang. Object.wait (Native Method)org. Quartz.simpl.simplethreadpool$workerthread.Run(simplethreadpool.java:568) 22-sep-2017 06:19:51.080 WARNING [main] Org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads the Web application [license] appears to has Started a thread named [org.springframework.scheduling.quartz.schedulerfactorybean#0_worker-10] but have failed to stop It. This was very likely
Step 1:configure Jobs in Quartz SchedulerA:using MethodinvokingjobdetailfactorybeanTargetObject the class to executeTargetmethod to execute the methods in the classConcurrent immediate execution immediately (when, after class instantiation)b:using JobdetailfactorybeanJobclass the class to be executed by the configuration taskJobdatamap Configuring parameter settings in the execution classStep 2:configure Triggers to being used in
Quartz is a powerful enterprise-level task scheduling framework that inherits and simplifies quartz in spring, and looks at how quartz is configured in spring:First, write a test-dispatched class: (Quartzhelloworldjob.java) Package Com.jp.quartz; Public class quartzhelloworldjob { publicvoid dotask () { System.out.println ( "------HelloWorld Task Sc
Scheduler timing Scheduling system is required for most industry projects, the traditional spring-job mode, the personal feeling has been out, because there are a lot of problems, especially the timing of the addition of scheduling, modification, deletion, need to modify the XML, XML configuration in effect is nothing more than a hot deployment of gray-scale publishing scheme or directly stop, restart the server, completely can not do automatic startup, repair mode.Reminder: The application can
In the dynamic change of quartz scheduling time (1), using the Delete job and then reloading to implement dynamic change scheduling cycle, today, I carefully read the next Quartz API, found that another way to achieve this function.
Version:
1.8.6
RELATED links:
api:http://quartz-scheduler.org/api/1.8.0/
Http://quartz
The quartz framework is encapsulated in Spring's Scheduling.quartz package, making it possible to implement timed tasks without having to write any quartspring code at development time. Spring Methodinvokingjobdetailfactorybean Implementation of the JOB definition through Jobdetailbean. The latter is more practical, simply by specifying the classes to run and the methods to be run in the class, and Spring will automatically generate jobdetail that mee
Quartz is a powerful enterprise-class Schedule tool and the best open source Schedule tool at the moment. The quartz application is also integrated into spring, so let's talk about using quartz in spring.
1, quartz need to add quartz-1.6.x.jar above the package
2. Spring nee
When your application requires job scheduling, you can use quartz job scheduling to solve your problem.
Steps:
1. Add two reference files quartz. dll and quartz. XML, which can be downloaded from the attachment (/files/scottpei/quartz.dll.7z) or elsewhere.
2. Create a class to manage the scheduling of each job. Assume that the class is named quartzmanager.
Using
PDF files are stored in vector graphics, text, and bitmap dependent on resolutions and used in a series of instructions of programs. A PDF file can contain multiple pages of graphics and text. PDF can be used to create cross-platform, read-only documents, or to draw images dependent on resolutions.Quartz creates high-fidelity PDF documents for all applications, which retain the rendering operations of the application, as shown in 13-1. The results of the PDF document will be optimized through ot
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.