📄 sendreport.java
字号:
package cn.com.ffcs.lbp;
import java.io.IOException;
import java.io.PrintWriter;
import java.rmi.RemoteException;
import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import cn.com.chinatelecom.www.schema.ctcc.common.v2_1.PolicyException;
import cn.com.chinatelecom.www.schema.ctcc.common.v2_1.ServiceException;
import cn.com.chinatelecom.www.wsdl.ctcc.sms.notification.v2_1._interface.SmsNotification;
import cn.com.chinatelecom.www.wsdl.ctcc.sms.notification.v2_1.service.SmsNotificationServiceLocator;
import ffcs.logging.Log;
import ffcs.logging.LogFactory;
/**
* <p>
* Title: 小区推送二期发送回执程序
* </p>
* <p>发送回执</p>
* 每隔一段时间,将回执从队列中取出,并发送至小区推送系统的推送前置模块。
* 此Class做成Servlet只是为了让tomcat一起来时就能启动此类。
* doGet()和doPost()函数都是假的,没用。
* 主要工作是在init()里完成。
* <p>Copyright: 2008 福建福富软件技术股份有限公司 </p>
* <p>Company: 福建福富软件技术股份有限公司</p>
* @author chenxin
* @version 1.0 $Date:2009-03-11
*/
public class sendReport extends HttpServlet {
private Log log = LogFactory.getLog(sendReport.class);
private MessageCount emseCounter = MessageCount.getIsagMsgCount();
/**
* Constructor of the object.
*/
public sendReport() {
super();
}
/**
* Destruction of the servlet. <br>
*/
public void destroy() {
super.destroy(); // Just puts "destroy" string in log
// Put your code here
}
/**
* The doGet method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to get.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out
.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">");
out.println("<HTML>");
out.println(" <HEAD><TITLE>A Servlet</TITLE></HEAD>");
out.println(" <BODY>");
out.print(" This is ");
out.print(this.getClass());
out.println(", using the GET method");
out.println(" </BODY>");
out.println("</HTML>");
out.flush();
out.close();
}
/**
* The doPost method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to post.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out
.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">");
out.println("<HTML>");
out.println(" <HEAD><TITLE>A Servlet</TITLE></HEAD>");
out.println(" <BODY>");
out.print(" This is ");
out.print(this.getClass());
out.println(", using the POST method");
out.println(" </BODY>");
out.println("</HTML>");
out.flush();
out.close();
}
/**
* Initialization of the servlet. <br>
*
* @throws ServletException if an error occure
*/
public void init() throws ServletException {
Queue q=new Queue(1000);
/* Date date=new Date();
start(date,60*1000*1); //间隔,1min
*/
sendQueThread qthread=new sendQueThread();
}
/* public void start(Date date,long period) {
Timer timer=new Timer();
timer.schedule(new TimerTask() {
public void run() {
//循环从队列中取出回执,然后发送给推送前置
sendFromQueue();
}
},date,period);
}*/
class sendQueThread extends Thread {
sendQueThread() {
this.setDaemon(true);
start();
}
public void run() {
while (true) {
try {
sleep(10000);
sendFromQueue();
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
private void sendFromQueue(){
while(Queue.isEmpty()==false){
ReceiptReport report=(ReceiptReport)Queue.pop();
if(report.getReport_type()==ReceiptReport.type_sms){
try {
// 定义一个服务访问点(port)
SmsNotification sss = new SmsNotificationServiceLocator().getSmsNotification(report.getCallbackURL());
// //设置SOAP头
// HeaderSetter hdrSter=new HeaderSetter();
// hdrSter.setDownSoapHeader((org.apache.axis.client.Stub) sss,inside_dlv_smf);
// 调用服务
cn.com.chinatelecom.www.schema.ctcc.sms.v2_1.DeliveryInformation deliveryStatus=
new cn.com.chinatelecom.www.schema.ctcc.sms.v2_1.DeliveryInformation(report.getDA(),cn.com.chinatelecom.www.schema.ctcc.sms.v2_1.DeliveryStatus.DeliveredToNetwork);
sss.notifySmsDeliveryReceipt(report.getCorrelator(), deliveryStatus);
log.info("向前置模块发短信回执:"+report.toString());
/* Integer(0x00000001),"SMS Rquest");
Integer(0x80000001),"SMS ReceiptReport");
Integer(0x00000002),"MMS Rquest");
Integer(0x80000002),"MMS ReceiptReport");
Integer(0x00000003),"WAP Rquest");
Integer(0x80000003),"WAP ReceiptReport");
*/
emseCounter.incrementSend(1,0x80000001); // SMS ReceiptReport
}catch (PolicyException pliEx){
log.error("向ISAG发送短信回执时PolicyException:"+pliEx);
pliEx.printStackTrace();
}catch (ServiceException svrEx){
log.error("向ISAG发送短信回执时ServiceException:"+svrEx);
svrEx.printStackTrace();
}catch (RemoteException rmtEx){
log.error("向ISAG发送短信回执时远程错误:"+rmtEx);
rmtEx.printStackTrace();
} catch (Exception ex) {
ex.printStackTrace();
}
}else if(report.getReport_type()==ReceiptReport.type_mms){
try {
// 定义一个服务访问点(port)
cn.com.chinatelecom.www.wsdl.ctcc.multimedia_messaging.notification.v2_2._interface.MessageNotification sss
= new cn.com.chinatelecom.www.wsdl.ctcc.multimedia_messaging.notification.v2_2.service.MessageNotificationServiceLocator()
.getMessageNotification(report.getCallbackURL());
// //设置SOAP头
// HeaderSetter hdrSter=new HeaderSetter();
// hdrSter.setDownSoapHeader((org.apache.axis.client.Stub) sss,inside_dlv_smf);
// 调用服务
cn.com.chinatelecom.www.schema.ctcc.multimedia_messaging.v2_2.DeliveryInformation mms_deliveryStatus=
new cn.com.chinatelecom.www.schema.ctcc.multimedia_messaging.v2_2.DeliveryInformation(report.getDA(),cn.com.chinatelecom.www.schema.ctcc.multimedia_messaging.v2_2.DeliveryStatus.DeliveredToNetwork);
sss.notifyMessageDeliveryReceipt(report.getCorrelator(), mms_deliveryStatus);
log.info("向前置模块发彩信回执:"+report.toString());
/* Integer(0x00000001),"SMS Rquest");
Integer(0x80000001),"SMS ReceiptReport");
Integer(0x00000002),"MMS Rquest");
Integer(0x80000002),"MMS ReceiptReport");
Integer(0x00000003),"WAP Rquest");
Integer(0x80000003),"WAP ReceiptReport");
*/
emseCounter.incrementSend(1,0x80000002); // MMS ReceiptReport
}catch (PolicyException pliEx){
log.error("向ISAG发送彩信回执时PolicyException:"+pliEx);
pliEx.printStackTrace();
}catch (ServiceException svrEx){
log.error("向ISAG发送彩信回执时ServiceException:"+svrEx);
svrEx.printStackTrace();
}catch (RemoteException rmtEx){
log.error("向ISAG发送彩信回执时远程错误:"+rmtEx);
rmtEx.printStackTrace();
} catch (Exception ex) {
ex.printStackTrace();
}
}else if(report.getReport_type()==ReceiptReport.type_wap){
try {
// 定义一个服务访问点(port)
cn.com.chinatelecom.www.wsdl.ctcc.wap_push.notification.v1_0._interface.MessageNotification sss
= new cn.com.chinatelecom.www.wsdl.ctcc.wap_push.notification.v1_0.service.MessageNotificationServiceLocator()
.getMessageNotification(report.getCallbackURL());
// //设置SOAP头
// HeaderSetter hdrSter=new HeaderSetter();
// hdrSter.setDownSoapHeader((org.apache.axis.client.Stub) sss,inside_dlv_smf);
// 调用服务
cn.com.chinatelecom.www.schema.ctcc.wap_push.v1_0.DeliveryInformation mms_deliveryStatus=
new cn.com.chinatelecom.www.schema.ctcc.wap_push.v1_0.DeliveryInformation(report.getDA(),cn.com.chinatelecom.www.schema.ctcc.wap_push.v1_0.DeliveryStatus.DeliveredToNetwork);
sss.notifyMessageDeliveryReceipt(report.getCorrelator(), mms_deliveryStatus);
log.info("向前置模块发WAP PUSH回执:"+report.toString());
/* Integer(0x00000001),"SMS Rquest");
Integer(0x80000001),"SMS ReceiptReport");
Integer(0x00000002),"MMS Rquest");
Integer(0x80000002),"MMS ReceiptReport");
Integer(0x00000003),"WAP Rquest");
Integer(0x80000003),"WAP ReceiptReport");
*/
emseCounter.incrementSend(1,0x80000003); // WAP ReceiptReport
}catch (PolicyException pliEx){
log.error("向ISAG发送WAP PUSH回执时PolicyException:"+pliEx);
pliEx.printStackTrace();
}catch (ServiceException svrEx){
log.error("向ISAG发送WAP PUSH回执时ServiceException:"+svrEx);
svrEx.printStackTrace();
}catch (RemoteException rmtEx){
log.error("向ISAG发送WAP PUSH回执时远程错误:"+rmtEx);
rmtEx.printStackTrace();
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -