use of org.mobicents.smsc.library.Sms in project smscgateway by RestComm.
the class DeliveryCommonSbb method applyMprocRulesOnSuccess.
// *********
// applying of mproc rules
/**
* mproc rules applying for delivery phase for success case
*
* @param sms
* @param processingType
*/
protected void applyMprocRulesOnSuccess(Sms sms, ProcessingType processingType) {
// PostDeliveryProcessor - success case
MProcResult mProcResult = MProcManagement.getInstance().applyMProcDelivery(itsMProcRa, sms, false, processingType);
FastList<Sms> addedMessages = mProcResult.getMessageList();
if (addedMessages != null) {
for (FastList.Node<Sms> n = addedMessages.head(), end = addedMessages.tail(); (n = n.getNext()) != end; ) {
Sms smst = n.getValue();
TargetAddress ta = new TargetAddress(smst.getSmsSet().getDestAddrTon(), smst.getSmsSet().getDestAddrNpi(), smst.getSmsSet().getDestAddr(), smst.getSmsSet().getNetworkId());
this.sendNewGeneratedMessage(smst, ta);
if (this.logger.isInfoEnabled()) {
StringBuilder sb = new StringBuilder();
sb.append("Posting of a new message after DeliverySuccess: targetId=");
sb.append(smst.getSmsSet().getTargetId());
sb.append(", sms=");
sb.append(smst);
this.logger.info(sb.toString());
}
}
}
}
use of org.mobicents.smsc.library.Sms in project smscgateway by RestComm.
the class DeliveryCommonSbb method applyMprocRulesOnImsiResponse.
/**
* mproc rules applying for delivery phase after SRI successful response
*
* @param smsSet
* @param lstPermFailured
* @param processingType
*/
protected void applyMprocRulesOnImsiResponse(SmsSet smsSet, ArrayList<Sms> lstPermFailured, ArrayList<Sms> lstRerouted, ArrayList<Integer> lstNewNetworkId, ISDNAddressString networkNode, String imsiData) {
Sms sms = this.getMessageInSendingPool(0);
if (sms != null) {
while (true) {
MProcResult mProcResult = MProcManagement.getInstance().applyMProcImsiRequest(itsMProcRa, sms, imsiData, networkNode.getAddress(), networkNode.getNumberingPlan().getIndicator(), networkNode.getAddressNature().getIndicator());
if (mProcResult.isMessageDropped()) {
lstPermFailured.add(sms);
if (this.logger.isInfoEnabled()) {
StringBuilder sb = new StringBuilder();
sb.append("Dropping message after SRI response: targetId=");
sb.append(sms.getSmsSet().getTargetId());
sb.append(", sms=");
sb.append(sms);
this.logger.info(sb.toString());
}
this.commitSendingPoolMsgCount();
sms = this.obtainNextMessage(ProcessingType.SS7_SRI);
if (sms == null)
break;
else
continue;
}
if (mProcResult.isMessageIsRerouted()) {
// firstly we check if rerouting attempts was not too many
if (sms.getReroutingCount() >= MAX_POSSIBLE_REROUTING) {
StringBuilder sb = new StringBuilder();
sb.append("Rerouting message attempt after SRI response, but we have already rerouted ");
sb.append(MAX_POSSIBLE_REROUTING);
sb.append(" times before: targetId=");
sb.append(sms.getSmsSet().getTargetId());
sb.append(", newNetworkId=");
sb.append(mProcResult.getNewNetworkId());
sb.append(", sms=");
sb.append(sms);
this.logger.warning(sb.toString());
} else if (mProcResult.getNewNetworkId() == sms.getSmsSet().getNetworkId()) {
// we do not reroute for the same networkId
} else {
lstRerouted.add(sms);
lstNewNetworkId.add(mProcResult.getNewNetworkId());
if (this.logger.isInfoEnabled()) {
StringBuilder sb = new StringBuilder();
sb.append("Rerouting message after SRI response: targetId=");
sb.append(sms.getSmsSet().getTargetId());
sb.append(", newNetworkId=");
sb.append(mProcResult.getNewNetworkId());
sb.append(", sms=");
sb.append(sms);
this.logger.info(sb.toString());
}
this.commitSendingPoolMsgCount();
sms = this.obtainNextMessage(ProcessingType.SS7_SRI);
if (sms == null)
break;
else
continue;
}
}
break;
}
}
}
use of org.mobicents.smsc.library.Sms in project smscgateway by RestComm.
the class DeliveryCommonSbb method postProcessRerouted.
/**
* Processing messages that were rescheduled (sms.inSystem=sent in live database).
*
* @param lstRerouted
* @param lstNewNetworkId
*/
protected void postProcessRerouted(ArrayList<Sms> lstRerouted, ArrayList<Integer> lstNewNetworkId) {
// next we are initiating another delivering process
try {
for (int i1 = 0; i1 < lstRerouted.size(); i1++) {
Sms sms = lstRerouted.get(i1);
int newNetworkId = lstNewNetworkId.get(i1);
sms.setReroutingCount(sms.getReroutingCount() + 1);
sms.setTargetIdOnDeliveryStart(smsSet.getTargetId());
MessageUtil.createNewSmsSetForSms(sms);
sms.getSmsSet().setNetworkId(newNetworkId);
this.scheduler.injectSmsOnFly(sms.getSmsSet(), true);
}
} catch (Exception e) {
this.logger.severe("Exception when DeliveryCommonSbb.postProcessRerouted() - rerouting" + e.getMessage(), e);
}
}
use of org.mobicents.smsc.library.Sms in project smscgateway by RestComm.
the class MProcManagement method applyMProcDeliveryTempFailure.
public MProcResult applyMProcDeliveryTempFailure(final MProcRuleRaProvider anMProcRuleRa, Sms sms, ProcessingType processingType) {
if (this.mprocs.size() == 0) {
return new MProcResult();
}
FastList<MProcRule> cur = this.mprocs;
PostDeliveryTempFailureProcessorImpl pap = new PostDeliveryTempFailureProcessorImpl(this.smscPropertiesManagement.getDefaultValidityPeriodHours(), this.smscPropertiesManagement.getMaxValidityPeriodHours(), logger);
MProcMessage message = new MProcMessageImpl(sms, processingType, null);
try {
for (FastList.Node<MProcRule> n = cur.head(), end = cur.tail(); (n = n.getNext()) != end; ) {
MProcRule rule = n.getValue();
if (rule.isForPostDeliveryTempFailureState() && rule.matchesPostDeliveryTempFailure(message)) {
if (logger.isDebugEnabled()) {
logger.debug("MRule matches at DeliveryTempFailure phase to a message: rule: " + rule + "message: " + sms);
}
rule.onPostDeliveryTempFailure(anMProcRuleRa, pap, message);
}
}
} catch (Throwable e) {
logger.error("Exception when invoking rule.matches(message) or onPostDeliveryTempFailure(): " + e.getMessage(), e);
return new MProcResult();
}
FastList<MProcNewMessage> newMsgs = pap.getPostedMessages();
MProcResult res = new MProcResult();
FastList<Sms> res0 = new FastList<Sms>();
for (FastList.Node<MProcNewMessage> n = newMsgs.head(), end = newMsgs.tail(); (n = n.getNext()) != end; ) {
MProcNewMessageImpl newMsg = (MProcNewMessageImpl) n.getValue();
res0.add(newMsg.getSmsContent());
}
res.setMessageList(res0);
if (pap.isNeedDropMessages()) {
res.setMessageDropped(true);
}
if (pap.isNeedRerouteMessages()) {
res.setMessageIsRerouted(true);
res.setNewNetworkId(pap.getNewNetworkId());
}
return res;
}
use of org.mobicents.smsc.library.Sms in project smscgateway by RestComm.
the class MProcManagement method applyMProcPreDelivery.
public MProcResult applyMProcPreDelivery(final MProcRuleRaProvider anMProcRuleRa, Sms sms, ProcessingType processingType) {
if (this.mprocs.size() == 0) {
return new MProcResult();
}
FastList<MProcRule> cur = this.mprocs;
PostPreDeliveryProcessorImpl pap = new PostPreDeliveryProcessorImpl(this.smscPropertiesManagement.getDefaultValidityPeriodHours(), this.smscPropertiesManagement.getMaxValidityPeriodHours(), logger);
MProcMessage message = new MProcMessageImpl(sms, processingType, null);
try {
for (FastList.Node<MProcRule> n = cur.head(), end = cur.tail(); (n = n.getNext()) != end; ) {
MProcRule rule = n.getValue();
if (rule.isForPostPreDeliveryState() && rule.matchesPostPreDelivery(message)) {
if (logger.isDebugEnabled()) {
logger.debug("MRule matches at PreDelivery phase to a message: rule: " + rule + "message: " + sms);
}
rule.onPostPreDelivery(anMProcRuleRa, pap, message);
}
}
} catch (Throwable e) {
logger.error("Exception when invoking rule.matches(message) or onPostPreDelivery(): " + e.getMessage(), e);
return new MProcResult();
}
FastList<MProcNewMessage> newMsgs = pap.getPostedMessages();
MProcResult res = new MProcResult();
FastList<Sms> res0 = new FastList<Sms>();
for (FastList.Node<MProcNewMessage> n = newMsgs.head(), end = newMsgs.tail(); (n = n.getNext()) != end; ) {
MProcNewMessageImpl newMsg = (MProcNewMessageImpl) n.getValue();
res0.add(newMsg.getSmsContent());
}
res.setMessageList(res0);
if (pap.isNeedDropMessages()) {
res.setMessageDropped(true);
}
if (pap.isNeedRerouteMessages()) {
res.setMessageIsRerouted(true);
res.setNewNetworkId(pap.getNewNetworkId());
}
return res;
}
Aggregations