def publish()

in api/src/main/scala/com/gu/adapters/notifications/Notifications.scala [28:43]


  def publish(arn: String, msg: String, subject: String): Future[String] = {
    val request = new PublishRequest(props.snsTopicArn, msg, subject)
    val p = Promise[String]()

    snsClient.publishAsync(request, new AsyncHandler[PublishRequest, PublishResult]() {
      override def onError(e: Exception) = {
        logger.error(s"message to $arn has not been sent: $msg", e)
        p.failure(e)
      }
      override def onSuccess(request: PublishRequest, result: PublishResult) {
        p.success(result.getMessageId)
      }
    })

    p.future
  }