Last active
April 9, 2018 12:31
-
-
Save ctwoprod/b1e10c865a2a32076bcc44357b19c1a5 to your computer and use it in GitHub Desktop.
send queue to sqs using python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/python | |
| import boto3 | |
| # Create SQS client | |
| sqs = boto3.client('sqs',region_name='ap-southeast-1') | |
| queue_url = 'https://sqs.ap-southeast-1.amazonaws.com/862498237182/test-paywalletuser-sqs' | |
| # Send message to SQS queue | |
| response = sqs.send_message( | |
| QueueUrl=queue_url, | |
| DelaySeconds=10, | |
| MessageAttributes={ | |
| 'Title': { | |
| 'DataType': 'String', | |
| 'StringValue': 'The Whistler' | |
| }, | |
| 'Author': { | |
| 'DataType': 'String', | |
| 'StringValue': 'John Grisham' | |
| } | |
| }, | |
| MessageBody=( | |
| '{' | |
| '"username" : "ctw",' | |
| '"profileName" : "PF",' | |
| '"parentId":"4",' | |
| '"merchantId" : "2",' | |
| '"userId": "1",' | |
| '"email": "hxxhhrra",' | |
| '"phoneNumber" : "01910"' | |
| '}' | |
| ) | |
| ) | |
| print(response['MessageId']) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/python | |
| import boto3 | |
| import json | |
| # Create SQS client | |
| sqs = boto3.client('sqs',region_name='ap-southeast-1') | |
| queue_url = 'https://sqs.ap-southeast-1.amazonaws.com/862498237182/test-paywalletusercreate-sqs' | |
| username = 'suername' | |
| profile_name = 'yf' | |
| parent_id = '2j' | |
| merchant_id = '56' | |
| account_id = 't3' | |
| email = 'x11' | |
| phone = 'f112' | |
| # Send message to SQS queue | |
| body = {"username": username, | |
| "profileName": profile_name, | |
| "parentId": parent_id, | |
| "merchantId": merchant_id, | |
| "userId": account_id, | |
| "email": email, | |
| "phoneNumber": phone | |
| } | |
| response = sqs.send_message( | |
| QueueUrl=queue_url, | |
| DelaySeconds=10, | |
| MessageBody=json.dumps(body) | |
| ) | |
| print(response['MessageId']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment