in notification/app/notification/services/guardian/GuardianNotificationSender.scala [36:71]
override def sendNotification(notification: Notification, notificationReceivedTime: Instant): Future[SenderResult] = {
val result = for {
registrationCount <- countRegistration(notification.topic)
workerBatches = prepareBatch(notification, registrationCount, notificationReceivedTime)
sqsBatchResults <- sendBatch(workerBatches, harvesterSqsUrl)
} yield {
val failed = sqsBatchResults.flatMap(response => Option(response.getFailed).map(_.asScala.toList).getOrElse(Nil))
if (failed.isEmpty) {
Right(SenderReport(
senderName = Guardian.value,
sentTime = DateTime.now,
sendersId = None,
platformStatistics = None,
totalRegistrationCount = registrationCount
))
} else {
failed.foreach { failure =>
logger.error(s"Unable to queue notification ${notification.id}: " +
s"${failure.getId} - ${failure.getCode} - ${failure.getMessage}")
}
Left(GuardianFailedToQueueShard(
senderName = s"Guardian",
reason = s"Unable to queue notification. Please check the logs for notification ${notification.id}")
)
}
}
result.recover {
case NonFatal(e) =>
logger.error(e.getMessage, e)
Left(GuardianFailedToQueueShard(
senderName = s"Guardian",
reason = s"Unable to send notification, got an exception ${e.getMessage}"
))
}
}