def main(): """ full test of the asynchronous queue (for my purposes) :return: None """ rec = asynq.ASynQ( url= 'amqp://*****:*****@localhost:5672/%2F?connection_attempts=3&heartbeat_interval=3600', routing_key='norm_queue', sender=True) my_uuid = str(uuid.uuid4()) rec.client({"hej": "3", 'uuid': my_uuid}) rec = asynq.ASynQ( url= 'amqp://*****:*****@localhost:5672/%2F?connection_attempts=3&heartbeat_interval=3600', routing_key=my_uuid, sender=False, otq=True) rec.serve(cb=myprint) print("DONE!")
def main(): """ this function defines a test client, which sends a message every 4000 seconds :return: None """ rec = asynq.ASynQ(url='amqp://*****:*****@localhost:5672/?connection_attempts=3&heartbeat_interval=3600', routing_key='asynq_otq', sender=True, otq=True) rec.client({"hej": "3"})
def main(): """ this sets up a test asynq queue consumer :return: """ rec = asynq.ASynQ(url='amqp://*****:*****@localhost:5672/%2F?connection_attempts=3&heartbeat_interval=3600', routing_key='norm_queue', sender=False) rec.serve(otqcallback) print("HOV!!!")
def main(): """ this sets up a test asynq queue consumer :return: """ rec = asynq.ASynQ( url= 'amqp://*****:*****@localhost:5672/%2F?connection_attempts=3&heartbeat_interval=3600', routing_key='asynq_test', sender=False) try: rec.serve(testcallback) except KeyboardInterrupt: rec.stop()
def otqcallback(channel, method, properties, body): """ test callback. This simply prints the body :param channel: the channel :param method: method parameters :param properties: properties :param body: the body :return: None """ uuid = json.loads(body.decode('utf-8'))['uuid'] print("UUID RECEIVED : " + uuid) rec = asynq.ASynQ(url='amqp://*****:*****@localhost:5672/%2F?connection_attempts=3&heartbeat_interval=3600', routing_key=uuid, sender=True,otq=True) rec.client({"BANG": "TJU"})
def main(): """ this function defines a test client, which sends a message every 4000 seconds :return: None """ i = 0 try: while True: rec = asynq.ASynQ( url= 'amqp://*****:*****@localhost:5672/%2F?connection_attempts=3&heartbeat_interval=3600', routing_key='asynq_test', sender=True) rec.client({"hej": "3"}) #rec.client("HEJ") i += 1 time.sleep(4) except KeyboardInterrupt: pass