now encountering a problem is more regular tasks simultaneously when some tasks will be performed at a particular point in time missed ( see the log without any error message , but the second task is not performed )
As Figure: The first task is run once every 15 minutes , the execution time point per hour [ 0,15,30,45 ] ; second for every 10 minutes , the time point [ 0 , 10,20,30,40,50 ] ; each task is also open multiple threads to execute ;
executed once for each task the time used was about two minutes to see results found missing situations: for example, a 15-minute task hours only [ 0,30,45 ] performed a quarter of an hour , missing the first 15 minutes
The following is the configuration on the quartz
1.quartz.properties
# ============================================= ===============================
# Configure Main Scheduler Properties
# ============================================= ===============================
org.quartz.scheduler.instanceName = atpScheduler
org.quartz.scheduler.instanceId = AUTO
# ============================================= ===============================
# Configure ThreadPool
# ============================================= ===============================
orgorg.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool
org.quartz.threadPool.threadCount = 50
org.quartz.threadPool.threadPriority = 9
org.quartz.threadPool.threadsInheritContextClassLoaderOfInitializingThread = false
# ============================================= ===============================
# Configure JobStore
# ============================================= ===============================
# set misfire time to 3 mine
org.quartz.jobStore.misfireThreshold = 180000
org.quartz.jobStore.class = org.quartz.impl.jdbcjobstore.JobStoreTX
org.quartz.jobStore.tablePrefix = qrtz_
org.quartz.jobStore.isClustered = false
# ============================================= ===============================
# Configure Plugins
# ============================================= ===============================
org.quartz.plugin.triggHistory.class = org.quartz.plugins.history.LoggingJobHistoryPlugin
org.quartz.plugin.shutdownhook.class = org.quartz.plugins.management.ShutdownHookPlugin
org.quartz.plugin.shutdownhook.cleanShutdown = true
2.spring the applicationContext.xml:
3. perform each task when creating a new thread pool to run the task under the use case , perform the complete thread pool is closed , JAVA code below:
/ **
* process data
* /
@ Override
public void disposeData (List
ExecutorService servicePoolThread = Executors.newFixedThreadPool (task.getThread_num ()) ;/ / create a thread pool
try {
for (Thread t: publicThread) {
servicePoolThread.submit (t);
}
servicePoolThread.shutdown ();
boolean loop = true;
do {/ / wait for all threads to finish
loop =! servicePoolThread.awaitTermination (5, TimeUnit.SECONDS);
logger.info (uuid + "` ====== waiting for the end of All threads ====== ");
} while (loop);
logger.info (uuid + "` ====== shutdown the thread pool, main end ====== ");
} catch (InterruptedException e) {
servicePoolThread.shutdownNow ();
Thread.currentThread (). interrupt ();
logger.error (uuid + "` ==== error in run periodJob (disposeData) ---> "+ e.getMessage ());
e.printStackTrace ();
}
}
============================================== ==============================================
thread calls the above procedure on the general situation in a number of online solutions
(1). possible web shutdown process does not close properly quartz, quartz executed after the next restart causes a problem
in the listener 's added quartz shutdown method ,
web.xml increased memory cleanup monitoring org.springframework.web.util.IntrospectorCleanupListener
quartz is turned off no problem, but the task execution times or miss
(2). suspected the same time concurrent capacity, the task has not been assigned to perform ,
put into each task cron expression disperse start: for example, 00 / 15 *** ? 06 /10 *** ?
still useless
looking for a real-time monitoring tool for your computer threads , thread execution when it found no significant increase in the total amount , has been ( 820-850 ) between
(3).
completion of each task performed at most no more than 3 minutes, I put the task timeout (misfireThreshold) set to 5 minutes to make sure the task will not start due to a timeout ; ineffective ;
looking for a couple of days really do not know why he would not perform , which the Supreme encountered this situation ? Pointing pointing , very grateful !
No points all to the
------ Solution ------------------------------ --------------
my side version : MethodInvokingJobDetailFactoryBean realization of concurrent field whether concurrent execution .
implemented as follows:
Class jobClass = (this.concurrent? (Class) MethodInvokingJob.class: StatefulMethodInvokingJob.class);
------ For reference only - -------------------------------------
is not configured for a single task serial execution , the first time the trigger point is not executed , it will not trigger , but continue to perform tasks not completed until the next trigger point .
------ For reference only -------------------------------------- -
My Job is inherited org.quartz.Job ( stateless ) , this is not to ensure that the same task can be complicated ?
------ For reference only ---------------------------------- -----
above two implementations are inherited org.quartz.Job.
------ For reference only -------------------------------------- -
is my database connection pool , the task execution did not get connected to the output of the error log
sloppy did not see . . . .
still thank you for your answer
没有评论:
发表评论