Quartz configuration in spring (can be used to implement mail timing, task execution, site timing updates, etc.)

Source: Internet
Author: User

Http://www.cnblogs.com/kay/archive/2007/11/02/947372.html

Issues that a message or task sends or executes more than once:

1.<property name= "Concurrent" value= "false"/> can be used to prevent tasks from executing multiple times

2. Separate the quartz configuration to prevent Tomcat from loading spring.

Specific practices: http://blog.csdn.net/zhujianpengzha/article/details/8140442

When using Spring's quartz timer recently, it was found that the task was always repeated two times after the time, under Tomcat or JBoss.
Print out their hashcode, found to be different, that is, when the Web container is started, the two quartz threads are restarted repeatedly.
Research down finds that quartz does load two times:
First: When the Web container starts, it is loaded once when the Applicationcontext.xml file is read.
Second time: Spring itself will load applicationcontext.xml once.
And my quartz configuration is written in the Applicationcontext.xml file.

The solution is simple.
First extract the quartz configuration information and save it as a single file, such as Applicationcontext-quartz.xml
You can then modify Web. xml so that when it starts, the file is loaded

This quartz will only load once when the Web container is started, and spring will no longer load. The Web. XML is configured as follows: <context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/web-inf/classes/applicationcontext.xml,/web-inf/classes/applicationcontext-timertask.xml </param-value>
</context-param>
<!--turn on listening--
<listener>
<listener-class>
Org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener> the configuration of the timer is written in a separate configuration file, which is only loaded once when the Web container is started. This problem will also appear under Spring's timertask timer, the solution is the same, I hope you can help the heroes

Quartz configuration in spring (can be used to implement mail timing, task execution, site timing updates, etc.)

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.