Skip to content

Commit 459b3e6

Browse files
authored
Merge pull request #759 from crankycookie/jkwon/add-sqs-fifo
Adds the ability to use SQS FIFO queues.
2 parents d445566 + d24fbd0 commit 459b3e6

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

internal/endpoint/sqs.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import (
66
"sync"
77
"time"
88

9+
"github.com/tidwall/gjson"
10+
911
"github.com/aws/aws-sdk-go/aws"
1012
"github.com/aws/aws-sdk-go/aws/credentials"
1113
"github.com/aws/aws-sdk-go/aws/session"
@@ -108,11 +110,17 @@ func (conn *SQSConn) Send(msg string) error {
108110
}
109111

110112
queueURL := conn.generateSQSURL()
111-
// Send message
113+
// Create message
112114
sendParams := &sqs.SendMessageInput{
113115
MessageBody: aws.String(msg),
114116
QueueUrl: aws.String(queueURL),
115117
}
118+
if isFifoQueue(queueURL) {
119+
key := gjson.Get(msg, "key")
120+
id := gjson.Get(msg, "id")
121+
keyValue := fmt.Sprintf("%s#%s", key.String(), id.String())
122+
sendParams.MessageGroupId = aws.String(keyValue)
123+
}
116124
_, err := conn.svc.SendMessage(sendParams)
117125
if err != nil {
118126
fmt.Println(err)
@@ -145,3 +153,7 @@ func sqsRegionFromPlainURL(s string) string {
145153
}
146154
return ""
147155
}
156+
157+
func isFifoQueue(s string) bool {
158+
return strings.HasSuffix(s, ".fifo")
159+
}

0 commit comments

Comments
 (0)