-
Notifications
You must be signed in to change notification settings - Fork 0
/
sqs.py
27 lines (21 loc) · 876 Bytes
/
sqs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import boto3
from constants import AWS_REGION
import logging
logger = logging.getLogger()
logger.setLevel(logging.INFO)
logging.getLogger('boto3').setLevel(logging.WARNING)
logging.getLogger('botocore').setLevel(logging.WARNING)
def send_sqs_message(queue_url, data):
try:
session = boto3.session.Session()
client = session.client(
service_name = 'sqs'
,region_name = AWS_REGION
)
if queue_url and data:
msg_response = client.send_message(QueueUrl = queue_url
,MessageBody = data)
else:
logger.exception('Either the queue_url is invalid the data is invalid. {}.')
except Exception as error:
logger.exception(error)