seratch/AWScala

Change return type for SQS Message Deletion functions

lmserrano opened this issue · 4 comments

The delete message functions are returning Unit but they should return DeleteMessageResult and DeleteMessageBatchResult.

In trait SQS, in awscala.sqs:

  def delete(message: Message) = deleteMessage(message)
  def deleteMessage(message: Message, requestCredentials: Option[AWSSessionCredentials] = None): Unit = {
    val request = new aws.model.DeleteMessageRequest(message.queue.url, message.receiptHandle)
    requestCredentials.foreach(c => request.setRequestCredentials(c))
    deleteMessage(request)
  }
  def deleteMessages(messages: Seq[Message], requestCredentials: Option[AWSSessionCredentials] = None): Unit = {
    val batchId = Thread.currentThread.getId + "-" + System.nanoTime
    deleteMessageBatch(
      messages.head.queue,
      messages.zipWithIndex.map { case (msg, idx) => new DeleteMessageBatchEntry(s"${batchId}-${idx}", msg.receiptHandle) },
      requestCredentials)
  }
  def deleteMessageBatch(queue: Queue, messages: Seq[DeleteMessageBatchEntry], requestCredentials: Option[AWSSessionCredentials] = None): Unit = {
    val request = new aws.model.DeleteMessageBatchRequest(
      queue.url,
      messages.map(_.asInstanceOf[aws.model.DeleteMessageBatchRequestEntry]).asJava)
    requestCredentials.foreach(c => request.setRequestCredentials(c))
    deleteMessageBatch(request)
  }

Fair enough. If you’re in a hurry, could you make a pull request for this?

Thank you for the quick reply. I'll try to make a pull request for this as soon as I have the chance.

@lmserrano Thank you for your contribution. I just released version 0.8.1 which includes your change. https://oss.sonatype.org/content/repositories/releases/com/github/seratch/awscala-s3_2.12/0.8.1/

Thank you @seratch .