弹簧石英阻塞螺纹
目前,我正在使用弹簧石英在不同时间执行三项不同的工作。我为每个触发器使用三个不同的调度程序。 这种情况在前几个小时内运行良好,但随后所有石英线程都会被阻塞。以下是我的 bean 定义:
> <!-- TRAFFIC POLLER DECLERATION -->
> <!-- job -->
> <bean id="TriggerJob" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
> <property name="targetObject" ref="TriggerClass" />
> <property name="targetMethod" value="trigger" />
> </bean>
>
> <!-- trigger -->
> <bean id="trigger1" class="org.springframework.scheduling.quartz.CronTriggerBean">
> <property name="jobDetail" ref="TriggerJob" />
> <property name="cronExpression" value="${trigger.cron}" />
> </bean>
>
> <!-- SCHEDULER -->
> <bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
> <property name="waitForJobsToCompleteOnShutdown" value="true" />
> <property name="triggers">
> <list>
> <ref bean="trigger1" />
> </list>
> </property>
> </bean>
以下是来自我的 jconsole 的被阻止线程的堆栈跟踪:
Name: org.springframework.scheduling.quartz.SchedulerFactoryBean#1_Worker-5
State: BLOCKED on java.lang.Object@131b502 owned by: org.springframework.scheduling.quartz.SchedulerFactoryBean#1_Worker-6
Total blocked: 20 Total waited: 101,919
Stack trace:
com.ecs.Trigger.TriggerClass trigger(TriggerClass.java:89)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
org.springframework.util.MethodInvoker.invoke(MethodInvoker.java:273)
org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean$MethodInvokingJob.executeInternal(MethodInvokingJobDetailFactoryBean.java:264)
org.springframework.scheduling.quartz.QuartzJobBean.execute(QuartzJobBean.java:86)
org.quartz.core.JobRunShell.run(JobRunShell.java:216)
org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:549)
任何人都知道我为什么会这样?提前致谢。
Currently, I am using spring quartz to fire three different jobs at different times. I am using three different schedulers for each trigger.
This scenario works fine for the first couple of hours but then all quartz threads become blocked. The following is my bean definition:
> <!-- TRAFFIC POLLER DECLERATION -->
> <!-- job -->
> <bean id="TriggerJob" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
> <property name="targetObject" ref="TriggerClass" />
> <property name="targetMethod" value="trigger" />
> </bean>
>
> <!-- trigger -->
> <bean id="trigger1" class="org.springframework.scheduling.quartz.CronTriggerBean">
> <property name="jobDetail" ref="TriggerJob" />
> <property name="cronExpression" value="${trigger.cron}" />
> </bean>
>
> <!-- SCHEDULER -->
> <bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
> <property name="waitForJobsToCompleteOnShutdown" value="true" />
> <property name="triggers">
> <list>
> <ref bean="trigger1" />
> </list>
> </property>
> </bean>
The following is the stack trace from my jconsole of the blocked threads:
Name: org.springframework.scheduling.quartz.SchedulerFactoryBean#1_Worker-5
State: BLOCKED on java.lang.Object@131b502 owned by: org.springframework.scheduling.quartz.SchedulerFactoryBean#1_Worker-6
Total blocked: 20 Total waited: 101,919
Stack trace:
com.ecs.Trigger.TriggerClass trigger(TriggerClass.java:89)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
org.springframework.util.MethodInvoker.invoke(MethodInvoker.java:273)
org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean$MethodInvokingJob.executeInternal(MethodInvokingJobDetailFactoryBean.java:264)
org.springframework.scheduling.quartz.QuartzJobBean.execute(QuartzJobBean.java:86)
org.quartz.core.JobRunShell.run(JobRunShell.java:216)
org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:549)
Anyone has got any idea why I am having this? Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
似乎工作(org.springframework.scheduling.quartz.SchedulerFactoryBean#1_Worker-5)正在与另一个org.springframework.scheduling.quartz.SchedulerFactoryBean#1_Worker-6同步,并正在等待这个释放资源。
你的工作中有一些 wait()/notify() 指令吗?
或者您是否在某些变量上同步相同的作业,而您没有在 TriggerJob 中设置?
您没有设置并发 = false,因此同一作业上的两个实例可能正在运行,而其中一个实例正在等待在另一个线程中执行的同一作业。
it seems that on job (org.springframework.scheduling.quartz.SchedulerFactoryBean#1_Worker-5) is synchronizing with another one org.springframework.scheduling.quartz.SchedulerFactoryBean#1_Worker-6 and is waiting for this one for releasing a resource.
Do you have some wait()/notify() instructions in your jobs?
or do you sinchronize the same job on some variable and you did not set in your TriggerJob?
You did not set concurrent=false so it may be that two instances on the same job are running and one is waiting for the same job executed in another thread.