Reputation: 133
Here is my lambda function. only return message-id and request-id. but how to verify the message is delivered or not?
const AWS = require('aws-sdk');
AWS.config.update({
accessKeyId: 'xxxx',
secretAccessKey: 'xxxx',
region: 'xxxx'
});
const mobile = 'xxxxxxx';
const sns = new AWS.SNS();
const confirmUpload = (callback) => {
sns.publish({
Message: 'Test From Admin side',
Subject: 'Admin',
MessageStructure: 'string',
PhoneNumber: mobile
}, (err, result) => {
if (err) callback(false, err);
else callback(true, result);
});
};
exports.handler = (event,context, callback) => {
confirmUpload((st, data) =>{
if(st){
let record = {
"data": JSON.stringify(data),
"event": event,
"context": context
};
callback(null, (record));
} else{
callback(data, "not send");
}
});
};
And here is the response when running the lambda function
"{\"ResponseMetadata\":{\"RequestId\":\"e8a07b26-d793-58e1-a529-2d7ac17aca9x\"},\"MessageId\":\"b8ecbcac-9f83-5bca-a9eb-eaf0896a69b\"}",
Upvotes: 4
Views: 6600
Reputation: 966
You can enable SNS dead-letter queues to catch messages that can’t be delivered to subscribers:
Upvotes: 0
Reputation: 60074
If you enable the delivery status feature on your topics you can use the message ID field in order to track the delivery status of the messages you have published.
After you configure the message delivery status attributes, log entries will be sent to CloudWatch Logs for messages sent to a topic subscribed to an Amazon SNS endpoint. Logging message delivery status helps provide better operational insight, such as the following:
Knowing whether a message was delivered to the Amazon SNS endpoint.
Identifying the response sent from the Amazon SNS endpoint to Amazon SNS.
Determining the message dwell time (the time between the publish timestamp and just before handing off to an Amazon SNS endpoint).
Configuring Delivery Status Logging Using the AWS Management Console
You can look into this article to look for delivery status using message ID
using-the-delivery-status-feature-of-amazon-sns
Btw I will not suggest to check in the same lambda but to configure cloud watch logs and filter failure topic only. Here will be flow
You may also like SLA for SNS by AWS.
Upvotes: 6