Skip to content

Instantly share code, notes, and snippets.

@ctwoprod
Last active April 9, 2018 12:31
Show Gist options
  • Save ctwoprod/b1e10c865a2a32076bcc44357b19c1a5 to your computer and use it in GitHub Desktop.
Save ctwoprod/b1e10c865a2a32076bcc44357b19c1a5 to your computer and use it in GitHub Desktop.

Revisions

  1. ctwoprod renamed this gist Apr 9, 2018. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. ctwoprod revised this gist Apr 9, 2018. 1 changed file with 22 additions and 19 deletions.
    41 changes: 22 additions & 19 deletions send_sqs.py
    Original file line number Diff line number Diff line change
    @@ -1,30 +1,33 @@
    !/usr/bin/python
    #!/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/xxx/test-sqs'
    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,
    MessageAttributes={
    'Title': {
    'DataType': 'String',
    'StringValue': 'The Whistler'
    },
    'Author': {
    'DataType': 'String',
    'StringValue': 'John Grisham'
    }
    },
    MessageBody=(
    'Information about current NY Times fiction bestseller for '
    'week of 12/11/2016.'
    QueueUrl=queue_url,
    DelaySeconds=10,
    MessageBody=json.dumps(body)
    )
    )

    print(response['MessageId'])
  3. ctwoprod revised this gist Apr 8, 2018. 1 changed file with 38 additions and 0 deletions.
    38 changes: 38 additions & 0 deletions send_json_sqs.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,38 @@
    #!/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'])
  4. ctwoprod created this gist Apr 6, 2018.
    30 changes: 30 additions & 0 deletions send_sqs.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,30 @@
    !/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/xxx/test-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=(
    'Information about current NY Times fiction bestseller for '
    'week of 12/11/2016.'
    )
    )

    print(response['MessageId'])