I am using logback in our java application for logging.
I want to send emails via AWS SNS whenever I encounter an error in my logs.
How can I do it for SNS?
Do I have to write a custom appender for it?
Yes. you will have to write a custom appender.
And also make sure that the email id to whom you want to send the email to, should first subscribe to the SNS topic. With SNS you cannot send emails to arbitrary email IDs that are not subscribed to the topic
Related
Good evening!
I receive an SNS inside an SQS Listner, and then I publish another SNS. Inside the SNS that I receive has a TraceId, how can I propagate this trace Id in the SNS that I send?
I thought about using spring-cloud-starter-sleuth, but I didn't find any usage example for this scenario.
Can anyone help me or give me some direction?
I need to maintain the status in the database if the email was delivered successfully or not, if the user has actually received the email or not,
when was the email delivered, email contents etc. for the purpose of auditing. How to do this ? Is there any API for this in AWS sdk ?
Its not as simple as just turning it on, but AWS does provide all the pieces you will need. This is how I do it currently
Turn on AWS delivery notifications, which will send the notifications to an SNS topic
Have that SNS topic delivery those messages to an SQS queue
Have a background job processing those messages and move them to a DynamoDB database for permanent storage.
The key part is #1, how you handle #2 and #3 is up to you - if I had to do it again I would use Lambda to takeover #3 for me, instead of using a custom job running on a dedicated Ec2 instance.
You can find out more about delivery notifications here:
https://docs.aws.amazon.com/ses/latest/DeveloperGuide/configure-sns-notifications.html#configure-feedback-notifications-console
also keep in mind, the tracking is not perfect - no email tracker is - SES uses some of the same techniques that mailchimp/constant contact use to determine if an email was opened, but it is far from foolproof.
You can configure Amazon SES to notify an Amazon SNS topic when you receive bounces or complaints, or when emails are delivered. Amazon SNS notifications are in JavaScript Object Notation (JSON) format, which enables you to process them programmatically.
Follow the steps :
Create topic in SNS
Subscribe to topic for delivery notifications(notifications are
pushed to AWS SNS topic in JSON format).
Subscribe to SNS in one of the following way:
Lambda
SQS
HTTP/S
Email
SMS
Considering the requirement of saving the JSON parameters in db table for purpose of auditing, you can listen to HTTP/S or SQS.
JSON response will have useful information like message id, notification type like complaints, bounce, delivery etc.
Am new to implement AWS SNS SMS gateway for my Java program. After the successful publishing message to AWS, I would like to know is the message send or not? Its always giving a response with messageId even the message fails to send. Is there any specific method or API to expose for this?
From the SNS FAQ:
Q: How do I track the delivery status of my SMS messages?
By enabling the Delivery Status feature in Amazon SNS, you can get information on the following for each message: MessageID, Time Sent, Destination Phone Number, Disposition, Disposition Reason (if applicable), Price, and Dwell Time.
In other words from the docs:
Amazon Simple Notification Service (Amazon SNS) provides support to log the delivery status of push notification messages. After you configure application attributes, log entries will be sent to CloudWatch Logs for messages sent from Amazon SNS to mobile endpoints. Logging message delivery status helps provide better operational insight, such as the following:
* Know whether a push notification message was delivered from Amazon SNS to the push notification service.
* Identify the response sent from the push notification service to Amazon SNS.
* Determine the message dwell time (the time between the publish timestamp and just before handing off to a push notification service).
Reference, check for code examples:
https://docs.aws.amazon.com/sns/latest/dg/sns-msg-status.html
So it seems you're up to using cloudwatch for this. The messageid you get from the API will of course be useful to filter for the information.
I suggest that you open a ticket for AWS support (because of your further questions as comments):
For professional support I suggest to open a case with them: https://console.aws.amazon.com/support/home#/case/create?issueType=service-limit-increase&limitType=service-code-sns-text-messaging
I am trying to integrate send promotional SMS messages to customers. For this can I use amazon SNS, and can I integrate this SNS with my web application?
I am using java and I want send group SMS with one click in my web application.
Also, is there any better solution rather than Amazon SNS?
Amazon SNS can send messages via SMS. Sending options are:
Send a message to a single recipient, or
Subscribe multiple recipients to an SNS topic, then send the message to the SNS topic. All subscribers will receive the message.
If you wish to send a different message to each recipient, use the first option. If you are regularly sending a message to the same group of recipients, use the second option. However, if the group of recipients frequently changes, it may be easiest to send each message individually.
See documentation: Sending SMS Messages with Amazon SNS
I am using aws sns for sending push notifications to devices(mobile devices mostly android). I am able to send notifications to individual devices but i want to publish a common message that has to be sent to all the active devices. I have created platform application and created the end points using all the device registration ids and also created the topic and subscribed to it but when i publish the message, the publish is success and i get the message id but i am not getting the notifications. I have implemented most of the methods which are in AmazonSNSClient class. If someone can guide me it would be very helpful.
Check the aws console in the website using your credentials there you will find details of the notifications sent. If you find that the notification is sent then probably the notification has failed. AWS does not guarantee the delivery of notifications.