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

📄 pushthread.java~1~

📁 WAP PUSH后台源码,WAP PUSH后台源码
💻 JAVA~1~
字号:
package test;

import java.io.IOException;
import java.sql.*;

import com.sxit.push.PushHQ2LC;
import com.sxit.push.PushHQ2LCService;
import com.sxit.push.PushHQ2LCServiceLocator;

public class PushThread extends Thread {
    public void run() {
        int times = 0;
        while (true) {
            try {
                int count = doExcute();
                if (count == 0) {
                    try {
                        sleep(10000L);
                    } catch (InterruptedException ie) {
                    }
                    if (++times == 2) {
                        times = 0;
                    }
                }
            } catch (IOException ioe) {
                System.out.println(ioe.getMessage());
            }

        }
    }

    public int doExcute() throws IOException {
        /* 发送次状态报告 */
        int count = 0;
        Connection conn = null;
        Statement stat = null;
        try {
            conn = DBUtil.getConnection();
            stat = conn.createStatement();
            ResultSet rs = stat.executeQuery("select t.id,t.frommdn,t.tomdn,c.title,c.url from t_pushlog t,t_channel c where t.channelid = c.id and t.sendflag = 0");
            while (rs.next()) {
                long id = rs.getLong(1);
                String fromMdn = rs.getString(2) ;
                String toMdn = rs.getString(3);
                String title = rs.getString(4);
                String url = rs.getString(5);
                String result = push(fromMdn,toMdn,title,url);
                try {
                    sleep(1000L);
                }catch(Exception e){
                }
                String[] resultItem = result.split(":");
                long iResult = 0 ;
                if (resultItem.length > 2) {
                    try {
                        iResult = Long.parseLong(resultItem[1]);
                    }catch (Exception e){
                    }
                }
                result = result.replaceAll("'","''");
                if (count ==0) {
                    stat.execute("delete from t_pushlog where toMdn in (select mdn from t_userblack)");
                    //stat.execute("delete from t_pushlog where toMdn in (select mdn from t_userblack)");
                }
                stat.execute("update t_pushlog set sendflag = 1 ,result = "+iResult+" memo = '" + result+"' where id="+id);
                count++;
                if (count>5000)
                    break ;
            }
            rs.close();
        } catch (SQLException se) {
            System.out.println(se.getMessage());
        } finally {
            try {
                if (stat != null)
                    stat.close();
                stat = null;
            } catch (SQLException e) {
                System.out.println(e.getMessage());
            }
            try {
                if (conn != null) {
                    conn.close();
                }
                conn = null;
            } catch (SQLException e) {
                System.out.println(e.getMessage());
            }
        }
        return count;
    }
    public String push(String fromMdn,String toMdn,String title,String url)  {
        try {
	        PushHQ2LCService service = new PushHQ2LCServiceLocator();
	        PushHQ2LC pushHQ = service.getPushService();
	    	String result ="";
	    	result = pushHQ.pushMSG2LC("059","059",fromMdn,toMdn,title,url);
	    	return result ;
        } catch(Exception e) {
            e.printStackTrace();
            return e.getMessage();
        }

    }
}

⌨️ 快捷键说明

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