LOGGER.debug("Sending message using sendMulti");
}
try {
String theMessage = message.getMessage();
SubmitMultiSM request = new SubmitMultiSM();
SubmitMultiSMResp response = null;
// set values
request.setServiceType(null);
request.setSourceAddr((String) null);
int numberOfDestinations = message.getDestinationCount();
for (int i = 0; i < numberOfDestinations; i++) {
String dest = message.getDestination(i);
final Address address;
if(dest.startsWith("+")) {
address =
new Address((byte) 0x01, (byte) 0x0, dest.substring(1));
} else {
address = new Address(dest);
}
request.addDestAddress(new DestinationAddress(address));
}
request.setServiceType(SMSCSvcType);
request.setSourceAddr(SMSCSvcAddr);
request.setReplaceIfPresentFlag((byte) 0x00);
request.setShortMessage(theMessage);
request.setEsmClass((byte) 0x00);
request.setProtocolId((byte) 0x00);
request.setPriorityFlag((byte) 0x00);
request.setRegisteredDelivery((byte) 0x00);
request.setDataCoding((byte) 0x00);
request.setSmDefaultMsgId((byte) 0x00);
// send the request
request.assignSequenceNumber(false);
if(LOGGER.isDebugEnabled()) {
LOGGER.debug("Submit request " + request.debugString());
}
// Get a session from the pool and attempt to send the message.
boolean submitted = false;
while (!submitted) {
Session SMSSession = (Session) sessionPool.borrowObject();
try {
response = SMSSession.submitMulti(request);
submitted = true;
sessionPool.returnObject(SMSSession);
} catch (Exception e) {
LOGGER.warn("message-submit-failure-retrying", e.getMessage());
sessionPool.invalidateObject(SMSSession);
}
}
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Submit response " + response.debugString());
}
if (response.getCommandStatus() != Data.ESME_ROK) {
throw new MessageException(
localizer.format("message-submit-failure"));
}
} catch (MessageException e) {
// don't wrap MessageExceptions