Reputation: 397
I'm attempting to send an SQS message to a FIFO queue. I've run into problems with the Message Group ID attribute. I thought using the MessageAttributeValue was the correct way to set up the "MessageGroupId", but AWS doesn't seem to recognize this input. What is the proper method for setting up SQS SendMessageRequest.MessageAttributes?
I've made a console project that sends a message. I've attempted a few things to set the Message Group Id attribute, but I get an exception when sending the message.
SendMessageRequest sendMessageRequest = new SendMessageRequest();
sendMessageRequest.QueueUrl = myURL;
MessageAttributeValue mavGroupID = new MessageAttributeValue();
mavGroupID.DataType = "MessageGroupId";
mavGroupID.StringValue = "1";
MessageAttributeValue mavDeDuplicateID = new MessageAttributeValue();
mavDeDuplicateID.DataType = "MessageDeduplicationId";
mavDeDuplicateID.StringValue = "1";
sendMessageRequest.MessageAttributes.Add("0", mavGroupID);
sendMessageRequest.MessageAttributes.Add("1", mavDeDuplicateID);
string sMyMessage = "";
Console.WriteLine();
Console.WriteLine("Message to send: ");
sMyMessage = Console.ReadLine();
sendMessageRequest.MessageBody = sMyMessage;
SendMessageResponse sMR = amazonSQSClient.SendMessage(sendMessageRequest);
Amazon.SQS.AmazonSQSException: 'The request must contain the parameter MessageGroupId.'
Upvotes: 10
Views: 21862
Reputation: 270089
The MessageGroupId
is specified on the SendMessageRequest
itself. It is not a MessageAttribute
.
SendMessageRequest.MessageGroupId = 'foo'
See: SendMessageRequest Class | AWS SDK for .NET V3
Upvotes: 12