All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.hengboy.job.schedule.runnable.MicroJobExecuteQueueRunnable Maven / Gradle / Ivy

The newest version!
package com.github.hengboy.job.schedule.runnable;

import com.github.hengboy.job.core.thread.JobThread;
import com.github.hengboy.job.schedule.queue.bean.JobQueueBean;
import com.github.hengboy.job.schedule.resource.MicroJobScheduleResource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @author:于起宇 

* ================================ * Created with IDEA. * Date:2019-01-25 * Time:16:38 * 个人博客:http://blog.yuqiyu.com * 简书:http://www.jianshu.com/u/092df3f77bca * 码云:https://gitee.com/hengboy * GitHub:https://github.com/hengyuboy * ================================ *

*/ public class MicroJobExecuteQueueRunnable implements Runnable { /** * logger instance */ static Logger logger = LoggerFactory.getLogger(MicroJobExecuteQueueRunnable.class); /** * 读取任务执行队列内等待执行的任务 * 每次读取一条,该线程项目启动后一直监听队列集合 */ @Override public void run() { while (true) { try { logger.debug("Current queue job count:{}", MicroJobScheduleResource.JOB_EXECUTE_QUEUE.size()); // 从队列内取出一个任务 JobQueueBean jobQueueBean = MicroJobScheduleResource.JOB_EXECUTE_QUEUE.take(); if (jobQueueBean != null) { JobThread.execute(new MicroJobExecuteRunnable(jobQueueBean)); } } catch (Exception e) { if (e instanceof InterruptedException) { logger.error("task from job queue error", e); } } } } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy