| | |
| | | package com.highdatas.mdm.util;
|
| | |
|
| | | import com.highdatas.mdm.service.DispenseService;
|
| | | import com.highdatas.mdm.util.pool.MqMessage;
|
| | | import lombok.extern.slf4j.Slf4j;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.context.annotation.Configuration;
|
| | | import org.springframework.scheduling.annotation.EnableScheduling;
|
| | | import org.springframework.scheduling.annotation.Scheduled;
|
| | |
|
| | | import java.io.IOException;
|
| | | import java.util.Date;
|
| | | import java.util.concurrent.PriorityBlockingQueue;
|
| | |
|
| | | /**
|
| | | * @author kimi
|
| | |
| | | @EnableScheduling
|
| | | @Slf4j
|
| | | public class TimeTasks {
|
| | | @Autowired
|
| | | DispenseService dispenseService;
|
| | | // @Autowired
|
| | | // DispenseService dispenseService;
|
| | |
|
| | | @Scheduled(fixedRate=1000 * 10)
|
| | | private void configureTasks() {
|
| | | PriorityBlockingQueue<Runnable> queue = dispenseService.getQueue();
|
| | | if (queue.isEmpty()) {
|
| | | return;
|
| | | }
|
| | | log.info("queue passiveQueueSize: {}", queue.size());
|
| | | for (Runnable runnable : queue) {
|
| | | if (!(runnable instanceof MqMessage)) {
|
| | | continue;
|
| | | }
|
| | | MqMessage mqMessage = (MqMessage) runnable;
|
| | | Date endTime = mqMessage.getEndTime();
|
| | | Date now = new Date();
|
| | | if (now.after(endTime)) {
|
| | | //timeout;
|
| | | try {
|
| | | mqMessage.printTimeOut();
|
| | | } catch (IOException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | // @Scheduled(fixedRate=1000 * 10)
|
| | | // private void configureTasks() {
|
| | | // PriorityBlockingQueue<Runnable> queue = dispenseService.getQueue();
|
| | | // if (queue.isEmpty()) {
|
| | | // return;
|
| | | // }
|
| | | // log.info("queue passiveQueueSize: {}", queue.size());
|
| | | // for (Runnable runnable : queue) {
|
| | | // if (!(runnable instanceof MqMessage)) {
|
| | | // continue;
|
| | | // }
|
| | | // MqMessage mqMessage = (MqMessage) runnable;
|
| | | // Date endTime = mqMessage.getEndTime();
|
| | | // Date now = new Date();
|
| | | // if (now.after(endTime)) {
|
| | | // //timeout;
|
| | | // try {
|
| | | // mqMessage.printTimeOut();
|
| | | // } catch (IOException e) {
|
| | | // e.printStackTrace();
|
| | | // }
|
| | | // }
|
| | | // }
|
| | | // }
|
| | | }
|