Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIFO queues require MessageGroupId in the send message #4

Open
ghost opened this issue Dec 28, 2017 · 1 comment
Open

FIFO queues require MessageGroupId in the send message #4

ghost opened this issue Dec 28, 2017 · 1 comment

Comments

@ghost
Copy link

ghost commented Dec 28, 2017

If the MessageGroupId the send message fails for FIFO queues.

I "hacked" a generated MessageGroupId for each message and set the field, and it worked.

However, I am wondering if it would be possible to set the MessageGroupId based on the src message? I'm not familiar enough with Go or the AWS SQS messages go api to provide a proper solution. Also, I have not tested my change for non-FIFO queues.

@ghost
Copy link
Author

ghost commented Dec 28, 2017

The simplistic hack, btw:

diff --git a/main.go b/main.go
index 3c7c42e..991e342 100644
--- a/main.go
+++ b/main.go
@@ -49,6 +49,8 @@ func main() {
                MessageAttributeNames: messageAttributeNames,
        }

+       counter := 0
+
        // loop as long as there are messages on the queue
        for {
                resp, err := client.ReceiveMessage(rmin)
@@ -71,11 +73,14 @@ func main() {
                        go func(m *sqs.Message) {
                                defer wg.Done()

+                               counter += 1
+                               msgGrpId :=  fmt.Sprintf("XXXXXX-%d", counter)
                                // write the message to the destination queue
                                smi := sqs.SendMessageInput{
                                        MessageAttributes: m.MessageAttributes,
                                        MessageBody:       m.Body,
                                        QueueUrl:          dest,
+                                       MessageGroupId:    &msgGrpId,
                                }

                                _, err := client.SendMessage(&smi)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants