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

📄 smsenderthread.java

📁 WAP PUSH后台源码,WAP PUSH后台源码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
                                   resp=m_sgipConn.submit(message.getSourceAddr(),message.getDestinationAddr(),
                                             message.getBinaryContent(),message.getSpNumber(),message.getCorpID(),message.getServiceType(),
                                             message.getFeeType(),message.getFeeValue(),message.getGivenValue(),
                                             message.getMorelatetoMTFlag(),message.getReportFlag(),4,"","");
                                   System.out.println(df.format(new Timestamp(System.currentTimeMillis()))+"第"+m_id+"条线程 成功发送小二进制文件");
//                                   SMSender.log.println(df.format(new Timestamp(System.currentTimeMillis()))+"第"+m_id+"条线程 成功发送小二进制文件");
                                   smssubmitthread=new SMSSubmitThread(resp,message.getSourceAddr(),message.getDestinationAddr(),
                                                     message.getContent(),message.getSpNumber(),message.getCorpID(),message.getServiceType(),
                                                     message.getFeeType(),message.getFeeValue(),message.getGivenValue(),
                                                     message.getMorelatetoMTFlag(),message.getReportFlag(),4,"","");
                                   newThread = new Thread(smssubmitthread);
                                   newThread.start();
                                   break;
                              case 3:
                                   num=message.binaryContentMulti.length;
                                   byte[][] bcm=message.getBinaryContentMulti();
                                   i=0;
                                   while(i<num-1){
                                        resp=m_sgipConn.submit(message.getSourceAddr(),message.getDestinationAddr(),
                                                  bcm[i],message.getSpNumber(),message.getCorpID(),"webdx",
                                                  0,"0",message.getGivenValue(),
                                                  message.getMorelatetoMTFlag(),message.getReportFlag(),4,"","");
                                        i++;
                                        System.out.println(df.format(new Timestamp(System.currentTimeMillis()))+"第"+m_id+"条线程 成功发送大二进制文件中的第"+i+"文件");
//                                        SMSender.log.println(df.format(new Timestamp(System.currentTimeMillis()))+"第"+m_id+"条线程 成功发送大二进制文件中的第"+i+"文件");

                                        smssubmitthread=new SMSSubmitThread(resp,message.getSourceAddr(),message.getDestinationAddr(),
                                                          bcm[i].toString(),message.getSpNumber(),message.getCorpID(),message.getServiceType(),
                                                          message.getFeeType(),message.getFeeValue(),message.getGivenValue(),
                                                          message.getMorelatetoMTFlag(),message.getReportFlag(),4,"","");
                                        newThread = new Thread(smssubmitthread);
                                        newThread.start();
                                   }
                                   resp=m_sgipConn.submit(message.getSourceAddr(),message.getDestinationAddr(),
                                             bcm[i].toString(),message.getSpNumber(),message.getCorpID(),message.getServiceType(),
                                             message.getFeeType(),message.getFeeValue(),message.getGivenValue(),
                                             message.getMorelatetoMTFlag(),message.getReportFlag(),4,"","");
                                   i++;
                                   System.out.println(df.format(new Timestamp(System.currentTimeMillis()))+"第"+m_id+"条线程 成功发送大二进制文件中的第"+i+"文件");
//                                   SMSender.log.println(df.format(new Timestamp(System.currentTimeMillis()))+"第"+m_id+"条线程 成功发送大二进制文件中的第"+i+"文件");
                                   smssubmitthread=new SMSSubmitThread(resp,message.getSourceAddr(),message.getDestinationAddr(),
                                                     message.getContent(),message.getSpNumber(),message.getCorpID(),message.getServiceType(),
                                                     message.getFeeType(),message.getFeeValue(),message.getGivenValue(),
                                                     message.getMorelatetoMTFlag(),message.getReportFlag(),4,"","");
                                   newThread = new Thread(smssubmitthread);
                                   newThread.start();
                                   break;
                              case 4:
                                   resp=m_sgipConn.submit(message.getSourceAddr(),message.getDestinationAddr(),
                                             message.getContent(),message.getSpNumber(),message.getCorpID(),message.getServiceType(),
                                             message.getFeeType(),message.getFeeValue(),message.getGivenValue(),
                                             message.getMorelatetoMTFlag(),message.getReportFlag(),0,"","");
                                   System.out.println(df.format(new Timestamp(System.currentTimeMillis()))+"第"+m_id+"条线程 成功发送小文本文件");
                                   System.out.println(df.format(new Timestamp(System.currentTimeMillis()))+"第"+m_id+"条线程 成功发送小文本文件");
                                   smssubmitthread=new SMSSubmitThread(resp,message.getSourceAddr(),message.getDestinationAddr(),
                                                     message.getContent(),message.getSpNumber(),message.getCorpID(),message.getServiceType(),
                                                     message.getFeeType(),message.getFeeValue(),message.getGivenValue(),
                                                     message.getMorelatetoMTFlag(),message.getReportFlag(),0,"","");
                                   newThread = new Thread(smssubmitthread);
                                   newThread.start();
                                   break;
                              case 5:
                                   num=message.contentMulti.length;
                                   String[] cm=message.getContentMulti();
                                   i=0;
                                   while(i<num-1){
                                        resp=m_sgipConn.submit(message.getSourceAddr(),message.getDestinationAddr(),
                                                  cm[i],message.getSpNumber(),message.getCorpID(),"webdx",
                                                  0,"0",message.getGivenValue(),
                                                  message.getMorelatetoMTFlag(),message.getReportFlag(),0,"","");
                                        i++;
                                        System.out.println(df.format(new Timestamp(System.currentTimeMillis()))+"第"+m_id+"条线程 成功发送大文本文件中的第"+i+"文件");
//                                        SMSender.log.println(df.format(new Timestamp(System.currentTimeMillis()))+"第"+m_id+"条线程 成功发送大文本文件中的第"+i+"文件");
                                        smssubmitthread=new SMSSubmitThread(resp,message.getSourceAddr(),message.getDestinationAddr(),
                                                          cm[i].toString(),message.getSpNumber(),message.getCorpID(),message.getServiceType(),
                                                          message.getFeeType(),message.getFeeValue(),message.getGivenValue(),
                                                          message.getMorelatetoMTFlag(),message.getReportFlag(),0,"","");
                                        newThread = new Thread(smssubmitthread);
                                        newThread.start();
                                   }
                                   resp=m_sgipConn.submit(message.getSourceAddr(),message.getDestinationAddr(),
                                             cm[i],message.getSpNumber(),message.getCorpID(),message.getServiceType(),
                                             message.getFeeType(),message.getFeeValue(),message.getGivenValue(),
                                             message.getMorelatetoMTFlag(),message.getReportFlag(),0,"","");
                                   i++;
                                   System.out.println(df.format(new Timestamp(System.currentTimeMillis()))+"第"+m_id+"条线程 成功发送大文本文件中的第"+i+"文件");
//                                   SMSender.log.println(df.format(new Timestamp(System.currentTimeMillis()))+"第"+m_id+"条线程 成功发送大文本文件中的第"+i+"文件");
                                   smssubmitthread=new SMSSubmitThread(resp,message.getSourceAddr(),message.getDestinationAddr(),
                                                     cm[i].toString(),message.getSpNumber(),message.getCorpID(),message.getServiceType(),
                                                     message.getFeeType(),message.getFeeValue(),message.getGivenValue(),
                                                     message.getMorelatetoMTFlag(),message.getReportFlag(),0,"","");
                                   newThread = new Thread(smssubmitthread);
                                   newThread.start();
                                   break;
                         }
                    } catch (Exception e) {
                         System.out.println(df.format(new Timestamp(System.currentTimeMillis()))+e);
//                         SMSender.log.println(df.format(new Timestamp(System.currentTimeMillis()))+e);
                         sendException = e;
                    }

                    if (sendException == null) {
                         System.out.println(df.format(new Timestamp(System.currentTimeMillis()))+"第"+m_id+"条线程 发送成功删除数据");
//                         SMSender.log.println(df.format(new Timestamp(System.currentTimeMillis()))+"第"+m_id+"条线程 发送成功删除数据");
                         queue.remove(message.getQueueID());
                         //发送成功
                    } else {
                         //发送失败
                         System.out.println(df.format(new Timestamp(System.currentTimeMillis()))+"第"+m_id+"条线程 发送失败恢复数据");
//                         SMSender.log.println(df.format(new Timestamp(System.currentTimeMillis()))+"第"+m_id+"条线程 发送失败恢复数据");
                         queue.reSendMessage(message.getQueueID());
                         //将消息放回到发送队列中
                         throw sendException;
                    }

                    //发送成功后,计数增一
                    count++;
                    long curTime = System.currentTimeMillis();

                    if (curTime - beginTime < 1000L) {
                         if (count >= SMSender.countOfSeconds) {
                              //sleep
                              //System.out.println("sleep");
                              Thread.currentThread().sleep(1000L - (curTime - beginTime));
                              count=0;
                         }
                    } else {
                         count = 0;
                    }
               }
          } catch (Exception e) {
               System.out.println(df.format(new Timestamp(System.currentTimeMillis()))+e);
//               SMSender.log.println(df.format(new Timestamp(System.currentTimeMillis()))+e);
          }finally{
               try {
                    if (m_dbConn != null) {
                         if (!m_dbConn.getAutoCommit()) {
                              m_dbConn.rollback();
                         }
                         m_dbConn.close();
                    }
               } catch (Exception ee) {
                    System.out.println(df.format(new Timestamp(System.currentTimeMillis()))+ee);
//                    SMSender.log.println(df.format(new Timestamp(System.currentTimeMillis()))+ee);
               }

          }
     }

     /**
      * SMSenderThread constructor comment.
      */
     public SMSenderThread(SgipConnection sgipConn,int id,int maxRetry,int waitingTime) {
          super();
          m_sgipConn = sgipConn;
          m_id = id+1;//线程id
          maxRetryTimes = maxRetry;//消息的最大发送尝试次数
          threadWaitingTime = waitingTime;//主控线程检测子线程活动状态间隔
     }

}

⌨️ 快捷键说明

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