I'm working on Amazon SNS and I've hit a wall in how to publish message to all endpoints registered to a specific application platform.
Do I have to create a topic that includes all target endpoints and publish to it?
What you can do in this case is to create an SNS topic and subscribe all endpoints to the topic. That way, whenever you publish a message to the topic, SNS will handle fanning it out to all subscribed endpoints for you.
Related
Im currently trying to design a scalable push notification service, which can send notifications to 5-10 mil users in a very short time. I came across two AWS related architectures which got me confused.
Use case: Send a notification to all the users.
1) Each device subscribes to an SNS topic, and if we want to send a push to all users, we just publish to the topics endpoint. And SNS handles the rest(sending to the million users)
2) Lambda functions are subscribed to SNS topics. We send a message to an SNS topic containing all the device tokens/batches, and then lambda calls APN/Firebase endpoints.
I fail to see in what case the second architecture would be beneficial compared to the first?
Mobile push notification :
sns endpoint will created based on user device token and you will get device token from Adm,Fcm,etc like push notification platform sdk and you can trigger push notification to perticular user based sns endpoint because each device have different endpoint and it created user device token and you will have track user device token and endpoint and userId and you can able to see aws sns mobile push notification console
1) you can create manually also
2) you can create endpoint using programmatically
you can refer below sdks to create via code https://docs.aws.amazon.com/sns/latest/dg/mobile-push-api.html
Lamda push notification
You can create sns topic in sns console and you can subscribe which lambda you want deliver notification
basically if you want connect one lamda to another lamda you can use those case
example 1:
you have micro service for sending otp to user and micro service deployed in different lambda and application recives sending otp request your application main lamda and now you need call otpservice lamda so you can create one sns topic and under subscription you can subscripe otp micro service lamda so main lamda will trigger otp service sns endpoint it will deliver notification micro service lamda
I am having an SNS topic name(Dev-Alert), I have created subscription to the topic and is receiving email, but i need to find out what services are publishing message to that topic. How can we back track it?
There is no 'breadcrumb' from an Amazon SNS topic pointing back to publishers.
In fact, a message can be published to an SNS topic with just a couple of lines of code from anywhere on the Internet (not just AWS services).
You will need to scan through the services themselves, looking for which ones are publishing to SNS rather than attempting to back-track.
Is there any way to publish a topic from Amazon SNS to multiple mobiles with Baidu cloud service?
Currently, when publish a message from SNS to baidu, I need specify EndpointArn which created with userid and channelid information. These information represent a mobile device.
==> I only publish from SNS to a specific mobile device represented by userid and channelid.
But I need publish a topic from SNS to multiple mobile devices which registered the topic.
I tried: smart phone register a topic (example: hello) to Baidu then SNS publish the same topic (hello) to Baidu. But the smartphone COULD NOT receive the topic message from SNS.
Anybody know how to make it work?
I just faced this problem, but finally find out it is required to set the following three message attributes for it to work:
AWS.SNS.MOBILE.BAIDU.DeployStatus
AWS.SNS.MOBILE.BAIDU.MessageType
AWS.SNS.MOBILE.BAIDU.MessageKey
Here is the reference:
https://docs.amazonaws.cn/sns/latest/dg/SNSMobilePushBaiduPublish.html
I want to build a pub/sub messaging system into my services that are hosted on Amazon Web Services, and creating SQS queues that subscribe to SNS topics seems like the obvious direction to take, but I can't get it working at all.
So far my code looks for the topics and the queues at startup and creates anything that's missing. This seems to work, I can see the SNS topic and the SQS queues in the AWS management console, and I can see that the queue is subscribed to the topic, but when I publish messages to the topic nothing ends up in the queue.
Even if I manually publish a message using the 'Publish' button in the management console the queue is still empty.
I changed the permissions on both the topic and the queue to 'everyone can do everything' just to eliminate this possibility. My code receives a message ID in response to the publish and there are no errors, every API call returns a 200 (OK) status.
Where can I go from here to figure out why it's not working?
The SNS --> SQS link has a few gotchas:
"Amazon SNS isn't currently compatible with FIFO queues." per the note on their Subscribing an Amazon SQS Queue to an Amazon SNS Topic Tutorial
You have to fiddle with the IAM permissions (see the page on Sending Amazon SNS Messages to Amazon SQS Queues)
You can't send messages to encrypted queues (see their Server-Side Encryption page)
It would definitely have been easier to figure this out if all this info were consolidated into a single page. The killer for me was #3 - perhaps one of these will be the solution to your issue.
A couple of options -
Enable CloudTrail and monitor the logs
View the CloudWatch logs to identify any permissions issues
Open a ticket with AWS support.
Ideally, you wouldn't be creating the resources in your application but instead decouple those into CloudFormation or at a minimum CLI scripts. If you require the ability to dynamically create these resources, using the AWS IoT Message Broker may be a better option since it supports ephemeral messaging resources - http://docs.aws.amazon.com/iot/latest/developerguide/iot-message-broker.html
I had a similar issue with SQS subscriptions. It turned out that if I create the subscription from the SQS editor it works, but if I create it from the SNS creation screen it accepts the message but never forwards it to the queue.
To get more detailed information about specific failures you can turn on
SNS "Delivery status logging".
Does AWS offer a service for real-time publish&subscribe messaging for end clients? (web, mobile, desktop).
I'm looking for something that is topic based, optionally with a statfull model of data, where clients can subscribe to topics, receive data published on these topics at real time, etc.
(similar to what Google Firebase offers).
Thanks.
Yes. Amazon Simple Notification Service (SNS) provides:
Topic creation
Publishing of messages to the topic
Subscription to a topic via:
Email
HTTP/S endpoint (effectively, a REST call)
SMS
Sending to an Amazon SQS queue
Triggering an AWS Lambda function
Sending mobile notifications (iOS, Android, Baidu, Windows mobile, Windows desktop, Mac desktop)