SPRING quartz定时器每天晚上会执行4次,求大师帮忙看看是什么原因~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

PeinJiang java  2015-07-10 09:38:46
代码如下:
<!-- 每日凌晨0点0分0秒启动定时器 -->
<bean id="cronReportTriggerDay" class="org.springframework.scheduling.quartz.CronTriggerBean">
<property name="jobDetail" ref="jobDayTask" />
<property name="cronExpression">
<value>0 0 0 * * ?</value>
</property>
</bean>
<bean id="jobDayTask" class="org.springframework.scheduling.quartz.JobDetailBean">
<property name="jobClass" value="com.sp2p.task.JobDayTask"></property>
</bean>



public class JobDayTask extends QuartzJobBean {

private static Log log = LogFactory.getLog(JobDayTask.class);
private static boolean isRunning = false;

private Object getBean(String beanName) {
return ContextLoader.getCurrentWebApplicationContext().getBean(beanName);
}

private Object getApplicationMap(String attrName){
return ContextLoader.getCurrentWebApplicationContext().getServletContext().getAttribute(attrName);
}

private void setApplicationMap(String attrName,Map<String,String> map){
ContextLoader.getCurrentWebApplicationContext().getServletContext().setAttribute(attrName, map);
}
@SuppressWarnings("unchecked")
@Override
protected void executeInternal(JobExecutionContext arg0)
throws JobExecutionException {
long start = System.currentTimeMillis();
//获取平台收费
Map<String,Object> platformCostMap = (Map<String, Object>) getApplicationMap(IAmountConstants.FEE_APPLICATION);
FrontMyPaymentService frontMyPayment = (FrontMyPaymentService) getBean("frontpayService");

JobTaskService jobTaskService = (JobTaskService) getBean("jobTaskService");

try {
Map<String,String> investMap = frontMyPayment.querInvesttou();
setApplicationMap("investMap", investMap);//放入全局变量中 用于前台二级菜单 金额的显示
if(!isRunning){
isRunning = true;
jobTaskService.autoPromoteIncome();
log.info("每日任务处理结束NEW");
isRunning = false;
}

} catch (Exception e) {
e.printStackTrace();
}finally{
platformCostMap = null;
}
log.info("用时 : " + (System.currentTimeMillis() - start) + "毫秒"
+"SystemMemery:freeMemory"+Runtime.getRuntime().freeMemory()+"-------maxMemory"+Runtime.getRuntime().maxMemory()+"-------totalMemory"+Runtime.getRuntime().totalMemory());
}
}
...全文
255 点赞 收藏 3
写回复
3 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
PeinJiang 2015-07-10
jobDayTask里面的executeInternal方法执行了4次 log.info("每日任务处理结束NEW");日志打印了4次
回复
qingyuan18 2015-07-10
你确定是quartz框架调用了你的class四次还是你的class业务逻辑导致做了四次? 打印一个你的class的初始时间戳,看是否quartz的问题
回复
Inhibitory 2015-07-10
log.info("每日任务处理结束NEW"); 可以加上些调试的信息,函数执行时间,调用堆栈都是调用了这个函数
回复
相关推荐
发帖
Web 开发
创建于2007-09-28

8.0w+

社区成员

Java Web 开发
申请成为版主
帖子事件
创建了帖子
2015-07-10 09:38
社区公告
暂无公告