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

Add support for attributes and delay seconds for SQS #65

Merged
merged 4 commits into from
Oct 5, 2023

Conversation

nickcaballero
Copy link
Contributor

@nickcaballero nickcaballero commented Sep 29, 2023

Adds support for sending SQS attributes and setting the delay seconds.

@nickcaballero nickcaballero marked this pull request as ready for review September 29, 2023 15:56
@viggu888
Copy link

viggu888 commented Oct 3, 2023

Hi,
I tried the below code on my local and getting this error while sending the message using that method with message attributes,

await sqs.sendMessage(testQueue, JSON.stringify({ value: '123' }), {
messageAttributes: {
'my-attribute': {
type: 'String',
value: 'my-attribute-value'
}
}
})

ERRO[0001] Uncaught (in promise) SQSServiceError: The type of message (user) attribute 'my-attribute' is invalid. You must use only the following supported type prefixes: Binary, Number, String.
running at bound construct (native)

@nickcaballero
Copy link
Contributor Author

Hi, I tried the below code on my local and getting this error while sending the message using that method with message attributes,

await sqs.sendMessage(testQueue, JSON.stringify({ value: '123' }), { messageAttributes: { 'my-attribute': { type: 'String', value: 'my-attribute-value' } } })

ERRO[0001] Uncaught (in promise) SQSServiceError: The type of message (user) attribute 'my-attribute' is invalid. You must use only the following supported type prefixes: Binary, Number, String. running at bound construct (native)

Ah yes, mixed up the value attribute with the DataType. Can you please try again?

Copy link
Member

@oleiade oleiade left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍🏻 🙇🏻

Left a request for a comment, to make the code easier to maintain, but great job overall and thank you so much for your contribution.

Once the other issue raised is addressed, I'll happily approve and merge this 🙇🏻

@@ -64,6 +64,22 @@ export class SQSClient extends AWSClient {
body = { ...body, MessageGroupId: options.messageGroupId }
}

if (typeof options.messageAttributes !== 'undefined') {
const attributeParameters = Object.entries(options.messageAttributes).reduce((params, [name, attribute], i) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This specific code would deserve some comment explaining what's going on. I had to read the docs and execute and log the code to figure it out myself: based on the attributes type, we match it to a specific object shape with the value field being different for each 😄 🙇🏻

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nickcaballero It worked now. Thanks for your help.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merci 🙇🏻

@oleiade oleiade merged commit baed8a3 into grafana:main Oct 5, 2023
@oleiade oleiade mentioned this pull request Nov 1, 2023
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

Successfully merging this pull request may close these issues.

3 participants