Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion pkg/services/awssqs.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,18 @@ func (s awsSqsService) Send(notif Notification, dest Destination) error {
}

func (s awsSqsService) sendMessageInput(queueUrl *string, notif Notification) *sqs.SendMessageInput {
return &sqs.SendMessageInput{
input := &sqs.SendMessageInput{
QueueUrl: queueUrl,
MessageBody: aws.String(notif.Message),
DelaySeconds: 10,
}

// Add MessageGroupId if available (required for FIFO queues)
if notif.AwsSqs != nil && notif.AwsSqs.MessageGroupId != "" {
input.MessageGroupId = aws.String(notif.AwsSqs.MessageGroupId)
}

return input
}
func (s awsSqsService) getQueueInput(dest Destination) *sqs.GetQueueUrlInput {
result := &sqs.GetQueueUrlInput{}
Expand Down
55 changes: 55 additions & 0 deletions pkg/services/awssqs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,61 @@ func TestGetClientOptionsCustomEndpointUrl_AwsSqs(t *testing.T) {
assert.Equal(t, 2, len(options))
}

func TestSendMessageInput_WithMessageGroupId_AwsSqs(t *testing.T) {
s := NewTypedAwsSqsService(AwsSqsOptions{})
queueUrl := "https://sqs.us-east-1.amazonaws.com/123456789012/test-queue.fifo"

notification := Notification{
Message: "Hello",
AwsSqs: &AwsSqsNotification{
MessageGroupId: "test-group-id",
},
}

input := SendMessageInput(s, &queueUrl, notification)

assert.Equal(t, &queueUrl, input.QueueUrl)
assert.Equal(t, "Hello", *input.MessageBody)
assert.Equal(t, int32(10), input.DelaySeconds)
assert.Equal(t, "test-group-id", *input.MessageGroupId)
}

func TestSendMessageInput_WithoutMessageGroupId_AwsSqs(t *testing.T) {
s := NewTypedAwsSqsService(AwsSqsOptions{})
queueUrl := "https://sqs.us-east-1.amazonaws.com/123456789012/test-queue"

notification := Notification{
Message: "Hello",
AwsSqs: &AwsSqsNotification{
MessageGroupId: "", // Empty string
},
}

input := SendMessageInput(s, &queueUrl, notification)

assert.Equal(t, &queueUrl, input.QueueUrl)
assert.Equal(t, "Hello", *input.MessageBody)
assert.Equal(t, int32(10), input.DelaySeconds)
assert.Nil(t, input.MessageGroupId) // Should not be set
}

func TestSendMessageInput_WithoutAwsSqsNotification_AwsSqs(t *testing.T) {
s := NewTypedAwsSqsService(AwsSqsOptions{})
queueUrl := "https://sqs.us-east-1.amazonaws.com/123456789012/test-queue"

notification := Notification{
Message: "Hello",
AwsSqs: nil, // No AWS SQS notification
}

input := SendMessageInput(s, &queueUrl, notification)

assert.Equal(t, &queueUrl, input.QueueUrl)
assert.Equal(t, "Hello", *input.MessageBody)
assert.Equal(t, int32(10), input.DelaySeconds)
assert.Nil(t, input.MessageGroupId) // Should not be set
}

// Helpers
var GetConfigOptions = (*awsSqsService).getConfigOptions
var GetClientOptions = (*awsSqsService).getClientOptions
Expand Down