diff --git a/rest/rest-sqs-testing-amazon-java-sdk/src/test/scala/org/elasticmq/rest/sqs/aws/AmazonJavaSdkNewTestSuite.scala b/rest/rest-sqs-testing-amazon-java-sdk/src/test/scala/org/elasticmq/rest/sqs/aws/AmazonJavaSdkNewTestSuite.scala index 4b088552..3a0c0f37 100644 --- a/rest/rest-sqs-testing-amazon-java-sdk/src/test/scala/org/elasticmq/rest/sqs/aws/AmazonJavaSdkNewTestSuite.scala +++ b/rest/rest-sqs-testing-amazon-java-sdk/src/test/scala/org/elasticmq/rest/sqs/aws/AmazonJavaSdkNewTestSuite.scala @@ -386,6 +386,25 @@ abstract class AmazonJavaSdkNewTestSuite messageAttributes(MessageGroupId) shouldBe "gp1" } + test("should ignore zero delay seconds on message level with fifo queue") { + // given + val queueUrl = + testClient.createQueue("testQueue1.fifo", Map(FifoQueueAttributeName -> "true", DelaySecondsAttributeName -> "5")) + testClient.sendMessage( + queueUrl, + "test123", + delaySeconds = Some(0), + messageGroupId = Option("group1"), + messageDeduplicationId = Option("dedup1") + ) + + // when + val messages = testClient.receiveMessage(queueUrl) + + // then + messages shouldBe empty + } + private def doTestSendAndReceiveMessageWithAttributes( content: String, messageAttributes: Map[String, MessageAttribute] = Map.empty, @@ -395,7 +414,7 @@ abstract class AmazonJavaSdkNewTestSuite ) = { // given val queue = testClient.createQueue("testQueue1") - testClient.sendMessage(queue, content, messageAttributes, awsTraceHeader) + testClient.sendMessage(queue, content, messageAttributes = messageAttributes, awsTraceHeader = awsTraceHeader) val message = receiveSingleMessageObject(queue, requestedAttributes, requestedSystemAttributes).orNull // then diff --git a/rest/rest-sqs-testing-amazon-java-sdk/src/test/scala/org/elasticmq/rest/sqs/client/AwsSdkV1SqsClient.scala b/rest/rest-sqs-testing-amazon-java-sdk/src/test/scala/org/elasticmq/rest/sqs/client/AwsSdkV1SqsClient.scala index 8e76f2d4..e981ba90 100644 --- a/rest/rest-sqs-testing-amazon-java-sdk/src/test/scala/org/elasticmq/rest/sqs/client/AwsSdkV1SqsClient.scala +++ b/rest/rest-sqs-testing-amazon-java-sdk/src/test/scala/org/elasticmq/rest/sqs/client/AwsSdkV1SqsClient.scala @@ -1,30 +1,7 @@ package org.elasticmq.rest.sqs.client import com.amazonaws.services.sqs.AmazonSQS -import com.amazonaws.services.sqs.model.{ - BatchResultErrorEntry, - CancelMessageMoveTaskRequest, - ChangeMessageVisibilityBatchRequest, - ChangeMessageVisibilityBatchRequestEntry, - CreateQueueRequest, - DeleteMessageBatchRequest, - DeleteMessageBatchRequestEntry, - GetQueueAttributesRequest, - GetQueueUrlRequest, - ListDeadLetterSourceQueuesRequest, - ListMessageMoveTasksRequest, - MessageAttributeValue, - MessageSystemAttributeValue, - PurgeQueueRequest, - QueueDoesNotExistException, - ReceiveMessageRequest, - ResourceNotFoundException, - SendMessageBatchRequest, - SendMessageBatchRequestEntry, - SendMessageRequest, - StartMessageMoveTaskRequest, - UnsupportedOperationException -} +import com.amazonaws.services.sqs.model.{BatchResultErrorEntry, CancelMessageMoveTaskRequest, ChangeMessageVisibilityBatchRequest, ChangeMessageVisibilityBatchRequestEntry, CreateQueueRequest, DeleteMessageBatchRequest, DeleteMessageBatchRequestEntry, GetQueueAttributesRequest, GetQueueUrlRequest, ListDeadLetterSourceQueuesRequest, ListMessageMoveTasksRequest, MessageAttributeValue, MessageSystemAttributeValue, PurgeQueueRequest, QueueDoesNotExistException, ReceiveMessageRequest, ResourceNotFoundException, SendMessageBatchRequest, SendMessageBatchRequestEntry, SendMessageRequest, StartMessageMoveTaskRequest, UnsupportedOperationException} import org.elasticmq._ import java.nio.ByteBuffer @@ -70,16 +47,21 @@ class AwsSdkV1SqsClient(client: AmazonSQS) extends SqsClient { override def sendMessage( queueUrl: QueueUrl, - messageBody: String, - messageAttributes: Map[String, MessageAttribute] = Map.empty, - awsTraceHeader: Option[String] = None, - messageGroupId: Option[String] = None, - messageDeduplicationId: Option[String] = None + messageBody: MessageMoveTaskStatus, + delaySeconds: Option[Int] = None, + messageAttributes: Map[ + MessageMoveTaskStatus, + MessageAttribute + ] = Map.empty, + awsTraceHeader: Option[MessageMoveTaskStatus] = None, + messageGroupId: Option[MessageMoveTaskStatus] = None, + messageDeduplicationId: Option[MessageMoveTaskStatus] = None ): Either[SqsClientError, Unit] = interceptErrors { client.sendMessage( new SendMessageRequest() .withQueueUrl(queueUrl) .withMessageBody(messageBody) + .withDelaySeconds(delaySeconds.map(Int.box).orNull) .withMessageSystemAttributes( mapAwsTraceHeader(awsTraceHeader) ) diff --git a/rest/rest-sqs-testing-amazon-java-sdk/src/test/scala/org/elasticmq/rest/sqs/client/AwsSdkV2SqsClient.scala b/rest/rest-sqs-testing-amazon-java-sdk/src/test/scala/org/elasticmq/rest/sqs/client/AwsSdkV2SqsClient.scala index 8bd9855e..30ba586b 100644 --- a/rest/rest-sqs-testing-amazon-java-sdk/src/test/scala/org/elasticmq/rest/sqs/client/AwsSdkV2SqsClient.scala +++ b/rest/rest-sqs-testing-amazon-java-sdk/src/test/scala/org/elasticmq/rest/sqs/client/AwsSdkV2SqsClient.scala @@ -39,17 +39,22 @@ class AwsSdkV2SqsClient(client: software.amazon.awssdk.services.sqs.SqsClient) e override def sendMessage( queueUrl: QueueUrl, - messageBody: String, - messageAttributes: Map[String, MessageAttribute] = Map.empty, - awsTraceHeader: Option[String] = None, - messageGroupId: Option[String] = None, - messageDeduplicationId: Option[String] = None + messageBody: MessageMoveTaskStatus, + delaySeconds: Option[Int] = None, + messageAttributes: Map[ + MessageMoveTaskStatus, + MessageAttribute + ] = Map.empty, + awsTraceHeader: Option[MessageMoveTaskStatus] = None, + messageGroupId: Option[MessageMoveTaskStatus] = None, + messageDeduplicationId: Option[MessageMoveTaskStatus] = None ): Either[SqsClientError, Unit] = interceptErrors { client.sendMessage( SendMessageRequest .builder() .queueUrl(queueUrl) .messageBody(messageBody) + .delaySeconds(delaySeconds.map(Int.box).orNull) .messageSystemAttributes(mapAwsTraceHeader(awsTraceHeader)) .messageAttributes(mapMessageAttributes(messageAttributes)) .messageGroupId(messageGroupId.orNull) diff --git a/rest/rest-sqs-testing-amazon-java-sdk/src/test/scala/org/elasticmq/rest/sqs/client/SqsClient.scala b/rest/rest-sqs-testing-amazon-java-sdk/src/test/scala/org/elasticmq/rest/sqs/client/SqsClient.scala index 9060f047..75bf990d 100644 --- a/rest/rest-sqs-testing-amazon-java-sdk/src/test/scala/org/elasticmq/rest/sqs/client/SqsClient.scala +++ b/rest/rest-sqs-testing-amazon-java-sdk/src/test/scala/org/elasticmq/rest/sqs/client/SqsClient.scala @@ -16,11 +16,15 @@ trait SqsClient { def sendMessage( queueUrl: QueueUrl, - messageBody: String, - messageAttributes: Map[String, MessageAttribute] = Map.empty, - awsTraceHeader: Option[String] = None, - messageGroupId: Option[String] = None, - messageDeduplicationId: Option[String] = None + messageBody: MessageMoveTaskStatus, + delaySeconds: Option[Int] = None, + messageAttributes: Map[ + MessageMoveTaskStatus, + MessageAttribute + ] = Map.empty, + awsTraceHeader: Option[MessageMoveTaskStatus] = None, + messageGroupId: Option[MessageMoveTaskStatus] = None, + messageDeduplicationId: Option[MessageMoveTaskStatus] = None ): Either[SqsClientError, Unit] def receiveMessage(