I am handling multiple log files and I have put a piece of code when something goes wrong and at the same time, I am pushing a message into AWS SQS that contains details of the error. Now I want to send an email to myself as soon as a message is pushed into SQS. Earlier I was trying to do using SES. I put SES email sending code but SQS was not playing role in it. What can I do to implement my use case?
except:
#this part runs for any corrupted file
sqs_msg_response = queue_client.send_message(MessageBody='Data Processing num_failed')
print('messageID',sqs_msg_response.get('MessageId'))
subject = 'Data file is not processed'
body='''the {}file is not processed at the time{}'''.format(string,current_time)
message = {"Subject":{"Data":subject},"Body":{"Html":{"Data":body}}}
email_response = email_client.send_email(
Source="xyz@gmail.com",
Destination={
"ToAddresses":[
"abc@gmail.com",
]
},
Message=message
)
Above I am implemented but SQS is independent and SES is independent. Now I want to implement as soon as message being pushed to SQS email being sent to the provided email id.
A regular pattern to solve this kind of issue is using a combination of Amazon SQS and Amazon SNS.
This way, the topic puts each message on the queue and sends an email at the same time.