⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sendmonitor.java

📁 中国联通短信通信协议
💻 JAVA
字号:
package com.wireless.sms.gwif.smsagent.workthread;

import java.util.*;
import com.wireless.sms.pub.mq.*;
import com.wireless.sms.gwif.smsagent.global.*;

public class SendMonitor {

  private static SendMonitor _instance = new SendMonitor();
  private Timer timer = null;
  private int mtcounter = 0;
  private int objcounter = 0;
  public static final int COMPUTE = 18;

  public static SendMonitor getInstance(){
    return _instance;
  }

  public void start(){
    if( timer == null ){
      timer = new Timer(true);
      timer.schedule(new TimerTask() {
        public void run() {

          try{
            int mtsize = GetMoMtGlobalForUsual.mtqueue.sizeByPriority();
            if (mtsize > 0) {
              mtcounter++;

              if (mtcounter > COMPUTE) {
                SmsGWIFGlobal.sendMonitor("I000001");
                LoggerConstant.mo_log.error("接口机 " +
                                          SmsGWIFGlobal.switchname +
                                          " " + SmsGWIFGlobal.getInstance().GATEWAY +
                                          " 未发送队列超过 " + mtsize);
//                ClientController.restartAll();
                mtcounter = 0;
              }
            }
            else {
              mtcounter = 0;
            }

            int objsize = ObjectQueue.getInstance().size();
            if (objsize > 0) {
              objcounter++;

              if (objcounter > COMPUTE) {
                SmsGWIFGlobal.sendMonitor("K000101");

                LoggerConstant.mo_log.error("接口机 " + SmsGWIFGlobal.switchname +
                                            " " + SmsGWIFGlobal.getInstance().GATEWAY +
                                            " 未发送入库队列超过 " + objsize);
                ObjectDbSender.stop();
                try{
                  Thread.sleep(5000);
                }catch(Exception e){}

                ObjectDbSender.start(SmsGWIFGlobal.OBJOUT_IP, SmsGWIFGlobal.OBJOUT_PORT);

                objcounter = 0;
              }
            }
            else {
              objcounter = 0;
            }

          }catch(Exception e){
            LoggerConstant.mo_log.error("Exception : ", e);
          }
        }
      }
      , 10000, 10000);
    }
  }

  public void stop(){
    if( timer != null ){
      timer.cancel();
      timer = null;
    }
  }

  public void setSendMTFlag(boolean sendFlag){

    if( sendFlag ){
      mtcounter = 0;
    }
  }

  public void setSendObjFlag(boolean sendFlag){

    if( sendFlag ){
      objcounter = 0;
    }
  }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -