private void sendPong(AGateway gateway, InboundMessage msg) { String pongResponse = (isCanonicalPingRequest(msg)) ? "pong" : getPseudoPongResponse(msg); LOG.debug("SmsPonger.sendPong: sending string '{}'", pongResponse); try { OutboundMessage pong = new OutboundMessage(msg.getOriginator(), pongResponse); pong.setGatewayId(gateway.getGatewayId()); if (!gateway.sendMessage(pong)) { LOG.error("Failed to send pong request to {}", msg.getOriginator()); } } catch (TimeoutException e) { LOG.error("Timeout sending pong request to {}", msg.getOriginator(), e); } catch (GatewayException e) { LOG.error("Gateway exception sending pong request to {}", msg.getOriginator(), e); } catch (IOException e) { LOG.error("IOException sending pong request to {}", msg.getOriginator(), e); } catch (InterruptedException e) { LOG.error("InterruptedException sending poing request to {}", msg.getOriginator(), e); } }
@Override public void process(AGateway gateway, Message.MessageTypes msgType, InboundMessage msg) { log.info(String.format("Inbound notification from (%s) with message (%s) of type (%s) received from gateway (%s)", msg.getOriginator(), msg.getText(), msgType.toString(), gateway.getGatewayId()));
@Override public void process(AGateway gateway, OutboundMessage msg) { log.info(String.format("[%s] Outbound notification for (%s) with message (%s) received from gateway (%s)", msg.getMessageStatus().toString(), msg.getRecipient(), msg.getText(), gateway.getGatewayId())); DateTime sentTime = newDateTime(msg.getDate()); if (sendingFailed(msg)) { if (msg.getRetryCount() >= maxRetries) { raiseFailureEvent(msg, sentTime); } else if (msg.getRetryCount() < maxRetries) { smsAuditService.log(new SmsRecord(OUTBOUND, msg.getRecipient(), msg.getText(), sentTime, KEEPTRYING, msg.getRefNo())); } } else { smsAuditService.log(new SmsRecord(SMSType.OUTBOUND, msg.getRecipient(), msg.getText(), sentTime, DeliveryStatus.DISPATCHED, msg.getRefNo())); } }