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

SNSProducer does not support MessageAttributes when publishing SNS messages #46

Open
massa-man opened this issue Feb 28, 2022 · 1 comment

Comments

@massa-man
Copy link

Thanks for making this library available, it is really useful. We are looking to implement this library in our project and came across a small issue. We currently have an events driven architecture, where we use a lot of SNS + SQS to route and fan out messages to different consumers. As multiple SQS queues might be subscribed to an SNS topic, we use MessageAttributes to filter out only the events the consumer needs to process and reduce the amount of lambda invocations.

We currently publish this way:

sns.publish({
  TopicArn: routerTopicArn,
  Message: JSON.stringify(event),
  MessageAttributes: {
    eventName: {
      DataType: 'String',
      StringValue: event.eventName || '',
    },
  },
});

And our SQS subscription filter policy to SNS looks something like this:

{
  "eventName": [
    "validation.create",
    "activity.process"
  ]
}

When looking closer at your SNSProducer we noticed you expose a sendJSON method that creates the JSON string and publishes the message, but does not allow us to pass any other inputs to the core SNS publish method, in our case MessageAttributes.

Would it be possible to add this support? I am happy to provide a patch for this is you accept contributions.

@ragaak
Copy link

ragaak commented Apr 20, 2022

can anyone please take a look at the open merge request?

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

2 participants