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

docs fix

parent cb676217
No related branches found
No related tags found
No related merge requests found
Pipeline #63907 passed with stages
in 2 minutes and 28 seconds
...@@ -110,7 +110,6 @@ Topic exchanges ...@@ -110,7 +110,6 @@ Topic exchanges
Topic exchanges are a bit harder. Let's try them: Topic exchanges are a bit harder. Let's try them:
.. code-block:: python .. code-block:: python
from coolamqp.cluster import Cluster from coolamqp.cluster import Cluster
...@@ -120,3 +119,17 @@ Topic exchanges are a bit harder. Let's try them: ...@@ -120,3 +119,17 @@ Topic exchanges are a bit harder. Let's try them:
c = Cluster(nd) c = Cluster(nd)
c.start() c.start()
xchg = Exchange('my-exchange', type='topic') xchg = Exchange('my-exchange', type='topic')
def handle_message(msg):
print(msg.body.tobytes().encode('utf-8'))
msg.ack()
queue = Queue(exchange=xchg, routing_key=b'test')
cons, fut = self.c.consume(queue, no_ack=False, on_message=handle_message)
fut.result()
self.c.publish(Message(b'test'), xchg, routing_key=b'test', confirm=True).result()
self.c.publish(Message(b'test'), xchg, routing_key=b'test2', confirm=True).result()
Note that the first message arrived, and the second did not. Also, notice how you didn't have to call
:meth:`~coolamqp.clustering.Cluster.declare` a single time, :meth:`~coolamqp.clustering.Cluster.consume` did all of that work for you
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