Skip to content
Snippets Groups Projects
Commit 75497bf2 authored by Piotr Maślanka's avatar Piotr Maślanka
Browse files

encoding

parent 50662d06
No related branches found
No related tags found
No related merge requests found
...@@ -16,12 +16,10 @@ your application that a disconnect happened. ...@@ -16,12 +16,10 @@ your application that a disconnect happened.
You only need to remember that: You only need to remember that:
1. Reconnects and redefinitions take a while. 1. Reconnects and redefinitions take a while. Things will happen during that time. It is your responsibility to ensure that your distributed system is built to handle this
* Things will happen during that time. It is your responsibility to ensure that your distributed system is built to handle this 2. CoolAMQP will tell you when it senses losing broker connection. It will also tell you when it regains the connection (that means that everything is redefined and ready to go)
2. CoolAMQP will tell you when it senses losing broker connection. 3. Delivering messages multiple times may happen. Ensure you know when it happens. Keywords: message acknowledgement, amqp specification
* It will also tell you when it regains the connection (that means that everything is redefined and ready to go) 4. CoolAMQP won't unserialize your messages. You send bags of bytes and properties, you get bags of bytes and their properties.
3. Delivering messages multiple times may happen.
* Ensure you know when it happens. Keywords: message acknowledgement, amqp specification
The project is actively maintained and used in a commercial project. Tests can run The project is actively maintained and used in a commercial project. Tests can run
either on Vagrant (Vagrantfile attached) or Travis CI, and run against RabbitMQ. either on Vagrant (Vagrantfile attached) or Travis CI, and run against RabbitMQ.
......
...@@ -13,7 +13,8 @@ class Message(object): ...@@ -13,7 +13,8 @@ class Message(object):
:type body: str (py2) or bytes (py3) :type body: str (py2) or bytes (py3)
:param properties: AMQP properties to be sent along :param properties: AMQP properties to be sent along
""" """
assert isinstance(body, six.binary_type) if not isinstance(body, six.binary_type):
raise TypeError('Message body must be binary!')
self.body = body self.body = body
self.properties = {} if properties is None else properties self.properties = {} if properties is None else properties
......
...@@ -42,6 +42,9 @@ class TestBasics(unittest.TestCase): ...@@ -42,6 +42,9 @@ class TestBasics(unittest.TestCase):
self.assertIs(self.amqp.drain(wait=1), None) self.assertIs(self.amqp.drain(wait=1), None)
def test_send_bullshit(self):
self.assertRaises(TypeError, lambda: Message(u'what the fuck'))
def test_nacknowledge(self): def test_nacknowledge(self):
myq = Queue('myqueue', exclusive=True) myq = Queue('myqueue', exclusive=True)
......
...@@ -85,7 +85,7 @@ class TestFailures(unittest.TestCase): ...@@ -85,7 +85,7 @@ class TestFailures(unittest.TestCase):
os.system("sudo service rabbitmq-server stop") os.system("sudo service rabbitmq-server stop")
self.assertIsInstance(self.amqp.drain(wait=4), ConnectionDown) self.assertIsInstance(self.amqp.drain(wait=4), ConnectionDown)
result = self.amqp.send(Message('what the fuck'), '', routing_key='wtf1') result = self.amqp.send(Message(b'what the fuck'), '', routing_key='wtf1')
result.cancel() result.cancel()
os.system("sudo service rabbitmq-server start") os.system("sudo service rabbitmq-server start")
...@@ -120,7 +120,7 @@ class TestFailures(unittest.TestCase): ...@@ -120,7 +120,7 @@ class TestFailures(unittest.TestCase):
os.system('sudo service rabbitmq-server restart') os.system('sudo service rabbitmq-server restart')
self.amqp.send(Message('hello'), xchg) self.amqp.send(Message(b'hello'), xchg)
self.assertIsInstance(self.amqp.drain(wait=4), ConnectionDown) self.assertIsInstance(self.amqp.drain(wait=4), ConnectionDown)
self.assertIsInstance(self.amqp.drain(wait=10), ConnectionUp) self.assertIsInstance(self.amqp.drain(wait=10), ConnectionUp)
self.assertIsInstance(self.amqp.drain(wait=4), MessageReceived) self.assertIsInstance(self.amqp.drain(wait=4), MessageReceived)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment