我想问..目前我正在使用 SMPP Logica 库..用于开发 SMSC 客户端...我正在使用 session.submit 向 smsc 服务器发送消息,发送消息几乎每秒 50 条消息,我想使用线程进行多次发送,因为我需要服务器的每个响应来获取传递报告......问题是...... session.submit 是线程安全的吗?我应该在使用线程发送消息之前先同步会话吗?我用来发送消息的代码是
{
response = session.submit(sm);
SUBMIT_SM_RESP(response,mt);
........
}
private void SUBMIT_SM_RESP(SubmitSMResp pdu,MTData mtd) {
log.info("CommandID From PDU "+pdu.getCommandId());
//SubmitSMResp submitSMResp = new SubmitSMResp();
if (pdu.getCommandId() == Data.SUBMIT_SM_RESP ){
// submitSMResp.setData(pdu.getData());
switch (pdu.getCommandStatus())
{
case 0:
log.info("Berhasil kirim MT; SeqNo=" + pdu.getSequenceNumber() + ";" + pdu.debugString());
break;
case 1031:
log.info("Error. Service not found; SeqNo=" + pdu.getSequenceNumber() + ";" +pdu.debugString());
break;
case 1032:
log.info("Error. Invalid TX Id; SeqNo=" + pdu.getSequenceNumber() + ";" +pdu.debugString());
break;
case 1033:
log.info("Error. Push limit exceeded; SeqNo=" + pdu.getSequenceNumber() + ";" + pdu.debugString());
break;
case 4107:
log.info("Error. Content Whitelisted (Testingmode); SeqNo=" + pdu.getSequenceNumber() + ";" +pdu.debugString());
break;
case 1280:
log.info("Insuficient Balance(Charging); SeqNo=" + pdu.getSequenceNumber() + ";" +pdu.debugString());
break;
}
log.debug("MT rec status: CommandID=SUBMIT_SM_RESP; SeqNo=" + pdu.getSequenceNumber() + "; CommandSts=" + pdu.getCommandStatus() + pdu.debugString());
//MTData mt = (MTData)DataInstance.getInstance().getHmSeqMT().get(Integer.valueOf(pdu.getSequenceNumber()));
MTData mt =mtd;
String tid = null;
if (mt == null) {
log.info("MT null");
// if (DataInstance.getInstance().getHmSeqTrxID().containsKey(Integer.valueOf(pdu.getSequenceNumber()))) {
// tid = (String)DataInstance.getInstance().getHmSeqTrxID().get(Integer.valueOf(pdu.getSequenceNumber()));
// mt = DataInstance.getInstance().getDbPrs().getMTTrxID(tid);
// log.info("MT rec status: CommandID=SUBMIT_SM_RESP; SeqNo=" + pdu.getSequenceNumber() + "; CommandSts=" + pdu.getCommandStatus() + "; trxid=" + tid + "; " + pdu.debugString());
// if (mt == null) {
log.info("MT rec status: CommandID=SUBMIT_SM_RESP; SeqNo=" + pdu.getSequenceNumber() + "; CommandSts=" + pdu.getCommandStatus() + "; trxid=" + tid + " n/a; " + pdu.debugString());
mt = DataInstance.getInstance().getDbPrs().getMTSeqNo(String.valueOf(pdu.getSequenceNumber()));
// }
// }
}
else {
tid = mt.getTransid();
}
// log.info(mt.getClass());
log.info("Transaction ID >>> "+mt.getTransid());
if (mt != null) {
DataInstance.getInstance().getDbPrs().deleteMT(mt,
String.valueOf(pdu.getCommandStatus()), DataInstance.getInstance().getTransX().operator);
DataInstance.getInstance().getHmSeqMT().remove(Integer.valueOf(pdu.getSequenceNumber()));
} else {
log.info("MT Null,,,Can't Send DR");
log.info("MT n/a: SeqNo=" + pdu.getSequenceNumber() + "; CommandSts=" + pdu.getCommandStatus() + pdu.debugString());
}
}
else
{
log.info("Nilai Enquiry Link "+Data.ENQUIRE_LINK_RESP);
}
}
问候
丹兹