use of org.jsmpp.InvalidResponseException in project dhis2-core by dhis2.
the class SMPPClient method send.
// -------------------------------------------------------------------------
// Supportive methods
// -------------------------------------------------------------------------
private OutboundMessageResponse send(SMPPSession session, String text, Set<String> recipients, SMPPGatewayConfig config) {
OutboundMessageResponse response = new OutboundMessageResponse();
SubmitMultiResult result = null;
try {
result = session.submitMultiple(config.getSystemType(), config.getTypeOfNumber(), config.getNumberPlanIndicator(), SOURCE, getAddresses(recipients), new ESMClass(), (byte) 0, (byte) 1, TIME_FORMATTER.format(new Date()), null, new RegisteredDelivery(SMSCDeliveryReceipt.SUCCESS_FAILURE), ReplaceIfPresentFlag.DEFAULT, new GeneralDataCoding(Alphabet.ALPHA_DEFAULT, MessageClass.CLASS1, config.isCompressed()), (byte) 0, text.getBytes());
log.info(String.format("Messages submitted, result is %s", result.getMessageId()));
} catch (PDUException e) {
log.error("Invalid PDU parameter", e);
} catch (ResponseTimeoutException e) {
log.error("Response timeout", e);
} catch (InvalidResponseException e) {
log.error("Receive invalid response", e);
} catch (NegativeResponseException e) {
log.error("Receive negative response", e);
} catch (IOException e) {
log.error("I/O error", e);
} catch (Exception e) {
log.error("Exception in submitting SMPP request", e);
}
if (result != null) {
if (result.getUnsuccessDeliveries() == null || result.getUnsuccessDeliveries().length == 0) {
log.info("Message pushed to broker successfully");
response.setOk(true);
response.setDescription(result.getMessageId());
response.setResponseObject(GatewayResponse.RESULT_CODE_0);
} else {
String failureCause = DeliveryReceiptState.valueOf(result.getUnsuccessDeliveries()[0].getErrorStatusCode()) + " - " + result.getMessageId();
log.error(failureCause);
response.setDescription(failureCause);
response.setResponseObject(GatewayResponse.FAILED);
}
} else {
response.setDescription(SENDING_FAILED);
response.setResponseObject(GatewayResponse.FAILED);
}
return response;
}
Aggregations