//主动发送 核心jar包是
//com.lxt2.client-api.2.2.0.0.jar
//com.lxt2.protocol
public class SMSDemo{
public static void main(String[] args) {
//第一步,初始化配置参数 配置参数放在相应的配置文件中
MsgConstant constant = MsgConstant.getInstance();
String propertiesPath = "./conf/config.properties";
constant.setPropertiesPath(propertiesPath);
constant.init();
//第二步,启动客户端引擎
ClientEngine client=new ClientEngine(
/**
* new RespReceiver(),
* new ReportReceiver(),
* new DeliverReceiver()
*代表IRespReceiver,IReportReceiver,IDeliverReceiver的接口实现类
*/
new RespReceiver(), //消息响应接口实现类
new ReportReceiver(), //状态报告接收接口实现类
new DeliverReceiver() //上行数据接收接口实现类
);
client.start();
//第三步,实例化短信对象
CbipSubmit Sms= new CbipSubmit();
sms.setDestMobiles("13945551222");
//第四步,创建主动发送器
ActiveSubmitSender sender = new ActiveSubmitSender();
//第五步,发送短信
sender.sendSubmit(sms);
}
}
//被动发送
public calss SMSSend2{
public static void main(String[] args) {
//第一步,初始化配置参数
MsgConstant constant = MsgConstant.getInstance();
String propertiesPath = "./conf/config.properties";
constant.setPropertiesPath(propertiesPath);
constant.init();
//第二步,启动客户端引擎
new ClientEngine(
new RespReceiver(),
new ReportReceiver(),
new DeliverReceiver()
new PassiveSubmitSender()
);
client.start();
}
public class PassiveSubmitSender implements IPassiveSubmitSender {
private MemoryQueue<IApiSubmit> queue;
public void setQueue(MemoryQueue<IApiSubmit> queue) {
this.queue = queue;
}
@Override
public IApiSubmit getSubmit() {
// 从自定义队列中获取数据
return queue.receive();
}
}
//properties文件
#SMS 客户端配置文件
#客户端ID
sms.clientID=1000
#用户名
sms.loginName=####
#密码
sms.password=###
#服务器IP
sms.serverIP=10.***.2.15
#服务器端口
sms.serverPort=1000
#产品ID
sms.productID=3000
#以下参数不建议修改
#连接数,建议填写2,不需修改
sms.connectNum=2
#输入缓冲
sms.inBufferSize=1024
#输出缓冲
sms.outBufferSize=1024
#缓存时间
sms.IdleTime=10
#滑动窗口(条)
sms.controlWindowsSize=16
#最大发送次数
sms.maxSendTime=3
#滑动窗口清理时间,单位是ms
sms.clearTimeOut=10000
#线程休眠时间,单位是ms
sms.clearSleepTime=10000
#失败重连接时间,单位是ms
sms.reconnectTime=3000
#是否重发,true是重发,false不重发,建议关闭重发
sms.reSend=false
转载于:https://my.oschina.net/u/2536011/blog/546218