📄 revthread.java~53~
字号:
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 RevThread 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 RevThread() { super("RevThread"); setDaemon(true); } public RevThread(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: CMPPDeliverMessage cmppDeliverMsg = (CMPPDeliverMessage) cmppMsg; System.out.println("Receive one MO: phone=" + cmppDeliverMsg.getDestTermianlId() + " content=" + cmppDeliverMsg.getMsgContent()); 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 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(); db.executeUpdate(UpdateSql); 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) { RevThread revThread1 = new RevThread(); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -