Ad

SQS Queue - Send Message Without MessageGroupId?

- 1 answer

I am trying to send a message without MessageGroupId because I basically don't need it. I have a few microservices running, that should read from the queue any time and if I put the same group ID it means that only one service can read these messages one by one.

Now generating an UUID as a MessageGroupId sounds like a bad practice. Is there a way to disable MessageGroupId or send a default value that won't act as a MessageGroupId?

const params = {
    MessageDeduplicationId: `${uuidv1()}`,
    MessageBody: JSON.stringify({
       name: 'Ben',
       lastName: 'Beri',
    }),
    QueueUrl: `https://sqs.us-east-1.amazonaws.com/${accountId}/${queueName}`,
};

sqs.sendMessage(params, (err, data) => {
    if (err) {
        console.log('error! ' + err.message);
        return;
    }
    console.log(data.MessageId);
});

error! The request must contain the parameter MessageGroupId.

Ad

Answer

We can't insert the message into the queue without messagegroupid, if you want messages to be picked sequentially, then use the same messagegroupid for all the messages, else use unique value for each. What are the implications you are facing with using UUID as messagegroupid

Ad
source: stackoverflow.com
Ad