Skip to content

Commit

Permalink
add test for reproducing #890
Browse files Browse the repository at this point in the history
  • Loading branch information
micossow committed Jun 13, 2024
1 parent 338afcd commit 63901d3
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 63901d3

Please sign in to comment.