Ejemplo n.º 1
0
def messages_write(name):
    """
	Write message to queue
	curl -s -X POST -H 'Accept: application/json' http://localhost:8080/queues/hello_world/msgs -d '{"content" : "this is a hello world queue"}'
	"""

    body = request.get_json(force=True)
    messageText = body['content']

    conn = get_conn()
    queue = conn.get_queue(name)
    queue.set_message_class(Message)
    m = Message()
    m.set_body(messageText)
    queue.write(m)

    resp = "Message " + messageText + " has been written to queue " + name + "\n"
    return Response(response=resp, mimetype="application/json")
Ejemplo n.º 2
0
def messages_write(name):
	"""
	Write message to queue
	curl -s -X POST -H 'Accept: application/json' http://localhost:8080/queues/hello_world/msgs -d '{"content" : "this is a hello world queue"}'
	"""

	body = request.get_json(force=True)
	messageText = body['content']

	conn = get_conn()
	queue = conn.get_queue(name)
	queue.set_message_class(Message)
	m = Message()
	m.set_body(messageText)
	queue.write(m)

	resp = "Message " + messageText + " has been written to queue "+ name +"\n"
	return Response(response=resp, mimetype="application/json")
Ejemplo n.º 3
0
def messages_write(name):
	"""
	Writee message to queue

	curl -s -X POST -H 'Accept: application/json' http://localhost:5000/queues/D15123353_Lab12/msgs -d '{"content": "this is the message I want to put on the queue"}' 
	curl -s -X POST -H 'Accept: application/json' 52.18.184.96:8080/queues/D15123353_Lab12/msgs -d '{"content": "this is the message I want to put on the queue"}'
	"""

	body = request.get_json(force=True)
	messageText = body['content']
	
	conn = get_conn()
	queue = conn.get_queue(name)
	queue.set_message_class(Message)
	m = Message()
	m.set_body(messageText)
	queue.write(m)
	
	resp = "Message "+messageText+" has been written to queue "+name+"\n"
	return Response(response=resp, mimetype="application/json")	
Ejemplo n.º 4
0
url = 'http://ec2-52-30-7-5.eu-west-1.compute.amazonaws.com:81/key'
req = urllib2.Request(url)
res = urllib2.urlopen(req)
key = res.read()
split = ':'
i = key.find(split)
word1 = key[:i]
word2 = key[i+len(split):]
res.close()

# Get the keys from a specific url and then use them to connect to AWS Service 
access_key_id = word1
secret_access_key = word2

# Set up a connection to the AWS service. 
conn = boto.sqs.connect_to_region("eu-west-1", aws_access_key_id=access_key_id, aws_secret_access_key=secret_access_key)

# Gets a queue and prints a message along side it 

q_name = sys.argv[1]

queue = conn.get_queue(q_name)

print "Message writing.."
queue.set_message_class(Message)
msg = Message()
msg.set_body(sys.argv[2])
queue.write(msg)
print "Done"
Ejemplo n.º 5
0
from credential import AWS_ACCESS_KEY, AWS_KEY
import time
import argparse
import boto.dynamodb

parser = argparse.ArgumentParser()
parser.add_argument('-s', '--queue', help='Local Worker')
parser.add_argument('-t',
                    "--worker",
                    default=1,
                    help='Number of Thread/Worker')
arg = parser.parse_args()
connection_ob = boto.connect_sqs(AWS_KEY, AWS_ACCESS_KEY)

queue = connection_ob.get_queue(arg.queue)
queue.set_message_class(RawMessage)
i = 0

start_time = time.time()
while True:
    dbconnection = boto.connect_dynamodb(AWS_KEY, AWS_ACCESS_KEY)
    rs = queue.get_messages(message_attributes='Values')
    if len(rs) != 0:
        msg = rs[0]
        id = rs[0].message_attributes['Values']['string_value']
        f = msg.get_body()
        # try:
        print "Connecting to Table...."
        table = dbconnection.get_table('task_table')

        if table.has_item(hash_key=id):