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

📄 getdeliverthread.java~25~

📁 短信网关发送接受平台。
💻 JAVA~25~
字号:
package smscenter;import cmpp12.*;import com.newpalm.smsgwapi.*;import com.newpalm.log.BatchLog;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2004</p> * <p>Company: </p> * @author unascribed * @version 1.0 */import java.io.*;public class GetDeliverThread extends Engine{    public SpConnector12 Connector = null;    public String updateSql = "update sms_submit set result = ";    public String whereSql = " where msg_id = ";    public DBConnection db = null;    public GetDeliverThread() {        super("RevThread");        setDaemon(true);    }    public GetDeliverThread(SpConnector12 spConnector){        super("RevThread");        setDaemon(true);        this.Connector = spConnector;        db = new DBConnection(Config.db_name,Config.db_host );    }    public void run(){        while(isRunning() ){            /*                接受deliver包            */            while(Config.IfConnected){                try{                    /*test*/                    CMPPMessage cmppMsg = null;                    try {                        cmppMsg = Connector.readMsg();                    }                    catch (Exception recvEx) {                        System.out.println(" Socket linker disconnect." + recvEx.toString());                        break;                    }                    if (cmppMsg == null) {                        BatchLog.info("receive one null Deliver");                        System.out.println("rev is null");                        continue;                    }                    //differentiate the message type by cmppMsg.getCommandID()                    //the message received may be CMPP_Deliver,CMPP_Submit_REP, or else.                    try {                        switch (cmppMsg.getCommandID()) {                            case CmppConstants.CMPP_Deliver:                                //MO包push到MOpool池中                                CMPPDeliverMessage cmppDeliverMsg = (CMPPDeliverMessage) cmppMsg;                                System.out.println("Receive one MO: phone=" +                                        cmppDeliverMsg.getDestTermianlId() +                                        " content=" + cmppDeliverMsg.getMsgContent() +                                        " dest_terminal_id = "+cmppDeliverMsg.getDestnationId() );                                Config.log.log("Receive one MO: phone=" +                                        cmppDeliverMsg.getDestTermianlId() +                                        " content=" + cmppDeliverMsg.getMsgContent() +                                        " dest_terminal_id = "+cmppDeliverMsg.getDestnationId());                                String insertSql = "insert sms_deliver "+                                        "(msg_id,src_terminal_id,msg_fmt,msg_content,"+                                        "arrive_time,submit_time,dest_terminal_id)values(";                                insertSql += String.valueOf(cmppDeliverMsg.getMsgId()) +",";                                insertSql += "'"+cmppDeliverMsg.getsrcTerminalId() +"',";                                insertSql += String.valueOf(cmppDeliverMsg.getMsgFmt()) +",";                                insertSql += "'"+cmppDeliverMsg.getMsgContent() +"',";                                insertSql += "'"+Utility.getDateString()+" "+Utility.getTimeString() +"',";                                insertSql += "'"+cmppDeliverMsg.getSubmitTime() +"',";                                insertSql += "'"+cmppDeliverMsg.getDestnationId() +"')";                                Config.moPool.push(insertSql);                                break;                            case CmppConstants.CMPP_Submit_REP:                                //Generally,by matching submit response msgid with sumit msgid,                                //you can find out the corresponding submit msg.                                //status=0 denotes success; other status's value denotes error code                                //Submit恢复包自动更新数据库                                CMPPSubmitRepMessage subRepMsg = (CMPPSubmitRepMessage) cmppMsg;                                System.out.println("Receive one MT Reply: MsgId=" +                                        subRepMsg.getMsgId() +                                        " status=" + subRepMsg.getResult());                                String UpdateSql = updateSql + subRepMsg.getResult() + whereSql + subRepMsg.getMsgId();                                System.out.println("***Get a CMPP_Submit_REP***:"+UpdateSql);                                try{                                    db.executeUpdate(UpdateSql);                                }catch(Exception e){                                    e.printStackTrace() ;                                }                                Config.log.log("Receive one MT Reply: MsgId=" +                                        subRepMsg.getMsgId() +                                        " status=" + subRepMsg.getResult());                                break;                            case CmppConstants.CMPP_Active_Test:                                break;                            case CmppConstants.CMPP_Terminate:                                break;                            case CmppConstants.CMPP_Query_REP:                                break;                            case CmppConstants.CMPP_Terminate_REP:                                break;                            case CmppConstants.CMPP_Active_Test_REP:                                break;                            case CmppConstants.CMPP_Cancel_REP:                                break;                        } //switch                        }catch(Exception e){                            e.printStackTrace() ;                        }                    /*test*/                }catch(Exception ex){                    ex.printStackTrace() ;                }                try{                    sleep(TimeConfig.TIME_ONE_SECOND*5);                }catch(Exception e){                    System.out.println("Exception In RevThread : "+e.toString() );                }            }//end while        }//end while    }//end run    public static void main(String[] args) {       GetDeliverThread revThread1 = new GetDeliverThread();    }}

⌨️ 快捷键说明

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