def test_get_msg(self): body = b'test-body' name = 'queue-name-get' rabbitpy.create_queue(queue_name=name) rabbitpy.publish(routing_key=name, body=body) result = rabbitpy.get(queue_name=name) self.assertEqual(result.body, body) rabbitpy.delete_queue(queue_name=name)
def test_get_msg(self): body = b'test-body' name = 'queue-name-get' rabbitpy.create_queue(os.environ['RABBITMQ_URL'], queue_name=name) rabbitpy.publish(os.environ['RABBITMQ_URL'], routing_key=name, body=body) result = rabbitpy.get(os.environ['RABBITMQ_URL'], queue_name=name) self.assertEqual(result.body, body) rabbitpy.delete_queue(os.environ['RABBITMQ_URL'], queue_name=name)
def test_publish_with_confirm(self): body = b'test-body' name = 'simple-publish' rabbitpy.create_queue(queue_name=name) self.assertTrue(rabbitpy.publish(routing_key=name, body=body, confirm=True)) result = rabbitpy.get(queue_name=name) self.assertEqual(result.body, body) rabbitpy.delete_queue(queue_name=name)
def test_publish_with_confirm(self): body = b'test-body' name = 'simple-publish' rabbitpy.create_queue(queue_name=name) self.assertTrue( rabbitpy.publish(routing_key=name, body=body, confirm=True)) result = rabbitpy.get(queue_name=name) self.assertEqual(result.body, body) rabbitpy.delete_queue(queue_name=name)
def test_publish_with_confirm(self): body = b'test-body' name = 'simple-consume-tests' rabbitpy.create_queue(queue_name=name) self.assertTrue(rabbitpy.publish(routing_key=name, body=body, confirm=True)) for message in rabbitpy.consume(queue_name=name, no_ack=True): self.assertEqual(message.body, body) break rabbitpy.delete_queue(queue_name=name)
def test_publish_with_confirm(self): body = b'test-body' name = 'simple-consume-tests' rabbitpy.create_queue(queue_name=name) self.assertTrue( rabbitpy.publish(routing_key=name, body=body, confirm=True)) for message in rabbitpy.consume(queue_name=name, no_ack=True): self.assertEqual(message.body, body) break rabbitpy.delete_queue(queue_name=name)
import rabbitpy for iteration in range(10): rabbitpy.publish('amqp://*****:*****@localhost:5672/%2f', '', 'test-messages', 'go') rabbitpy.publish('amqp://*****:*****@localhost:5672/%2f', '', 'test-messages', 'stop')
def publish_message(message, queue_name='hello'): if API_KEY: rabbitpy.publish(API_KEY, exchange_name='', routing_key=queue_name, body=message) return True else: return False
def publish_message(message, queue_name='hello'): rabbitpy.publish(API_KEY, exchange_name='', routing_key=queue_name, body=message)