Quartz Tutorial Lesson 11th advanced (Enterprise-level) features

Source: Internet
Author: User
Lesson 11th Advanced (Enterprise-Class) features 11.1 Cluster

The current cluster needs to work with Jdbcjobstore (Jobstoretx or JOBSTORECMT) and Terracottajobstore. This particular includes load balancing and job fault tolerance (if Jobdetail's "request Recovery" flag is set to true).

### #使能JobStoreTX或JobStoreCMT的集群, you need to set the "Org.quartz.jobStore.isClustered" property to True. A scheduler instance in a cluster uses the same quartz.properties file. Identical property files, you can allow the following exceptions: different thread pool sizes, different "org.quartz.scheduler.instanceId" property values. Each node in the cluster must have a unique Instanceid, which is easy to implement (without the need for a different property file), just set the value of this property to auto.

Note: Never run a cluster on a separate machine unless their clocks are synchronized, use some time synchronization service (daemon) and run very regularly (the clocks must is within a second of each). If you do not know how to implement it, see http://www.boulder.nist.gov/timefreq/service/its.htm.

Non-clustered instances are never triggered on the same datasheet that is run by another instance. This can cause serious data errors, and there will be some erratic behavior.

Each time a trigger is fired, only one node triggers the job. I mean, if the job has a duplicate trigger, tell it to fire every 10s, then only one node in 12:00:00 will run the job, and at 12:00:10 only one node will run the job, and so on. Each time it doesn't have to be the same node: it runs randomly on which node. For busy scheduler (with many trigger), the load-balancing mechanism is almost random, but for the less busy scheduler, it prefers to use the same active node.

### #使用TerracottaJobStore的集群, simple Configuration Scheduler using Terracottajobstore (the 9th lesson Jobstore introduced), your scheduler are used for clustering.

You also want to consider how to set up terracotta servers, especially the configuration options for opening features, such as persistence, running a set of terracotta servers to implement HA.

The Enterprise version of Terracottajobstore provides an advanced quartz where feature that allows intelligent job orientation to the appropriate cluster nodes.

For more information about Jobstore and terracotta, visit the Http://www.terracotta.org/quartz 11.2 JTA Transaction

As the 9th Lesson Jobstore introduces, JOBSTORECMT allows Quartz to perform scheduling operations in larger JTA transactions.

If Jobs wants to execute (usertransaction) in a JTA transaction, set the property "Org.quartz.scheduler.wrapJobExecutionInUserTransaction" to true. If this property is set, the JTA transaction calls the Begin () method before calling the job's Execute method, and the commit () method is invoked at the end of execute to apply to all jobs.

If you want to specify whether the job will let JTA transactions wrap its execution, then you should use @executeinjtatransaction annotations on the job class.

In addition to quartz, the job execution is automatically wrapped into a transaction, and calls on the scheduler interface participate in the transaction when JOBSTORECMT is used. Before calling the scheduler method, make sure that the transaction has started. You can either start directly by using usertransaction or put your code in the Sessionbean that uses the container hosting transaction.


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.