Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
coolamqp
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
public
coolamqp
Commits
0a5a76ec
Commit
0a5a76ec
authored
6 months ago
by
Piotr Maślanka
Browse files
Options
Downloads
Patches
Plain Diff
docs fix
parent
952fdf1a
No related branches found
No related tags found
No related merge requests found
Pipeline
#63902
passed with stages
in 2 minutes and 30 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
docs/index.rst
+1
-1
1 addition, 1 deletion
docs/index.rst
docs/reference.rst
+2
-2
2 additions, 2 deletions
docs/reference.rst
docs/tutorials.rst
+48
-1
48 additions, 1 deletion
docs/tutorials.rst
with
51 additions
and
4 deletions
docs/index.rst
+
1
−
1
View file @
0a5a76ec
...
@@ -7,7 +7,7 @@ Welcome to CoolAMQP's documentation!
...
@@ -7,7 +7,7 @@ Welcome to CoolAMQP's documentation!
whatsnew
whatsnew
cluster
cluster
tutorials
/send_and_receive
tutorials
how-to-guide
how-to-guide
caveats
caveats
frames
frames
...
...
This diff is collapsed.
Click to expand it.
docs/
cluster
.rst
→
docs/
reference
.rst
+
2
−
2
View file @
0a5a76ec
CoolAMQP cluster
CoolAMQP cluster
reference
================
================
==========
.. autoclass:: coolamqp.clustering.Cluster
.. autoclass:: coolamqp.clustering.Cluster
:members:
:members:
...
...
This diff is collapsed.
Click to expand it.
docs/tutorials
/send_and_receive
.rst
→
docs/tutorials.rst
+
48
−
1
View file @
0a5a76ec
Tutorials
=========
Send and receive
Send and receive
================
----------------
In this tutorial we'll learn how to declare a named queue and send a message to it with acknowledgement:
In this tutorial we'll learn how to declare a named queue and send a message to it with acknowledgement:
...
@@ -57,3 +60,47 @@ and then disconnect from the server
...
@@ -57,3 +60,47 @@ and then disconnect from the server
cons.cancel().result()
cons.cancel().result()
c.shutdown()
c.shutdown()
Fanout exchanges
----------------
Now let's try to do a fanout exchange:
.. code-block:: python
from coolamqp.cluster import Cluster
from coolamqp.objects import NodeDefinition, Exchange
nd = NodeDefinition('amqp://127.0.0.1:5672/vhost', user='test', password='test', heartbeat=30)
c = Cluster(nd)
c.start()
xchg = Exchange('my-exchange', type='fanout')
Now let's make two queues that will bind to this queue:
.. code-block:: python
from coolamqp.objects import Queue
q1 = Queue('my-queue-1', exchange=xchg)
q2 = Queue('my-queue-2', exchange=xchg)
def handle_message(msg):
print(msg.body.tobytes().encode('utf-8'))
msg.ack()
c.consume(q1, on_message=handle_message, no_ack=False)
c.consume(q2, on_message=handle_message, no_ack=False)
Note how you did not have to call :meth:`coolamqp.cluster.Cluster.declare`. Consume will declare constructs of arbitrary
complexity, if they can be derived from the queue objects you passed it.
And let's try to send something to this exchange:
.. code-block:: python
from coolamqp.objects import Message
c.publish(Message(b'my bag of bytes'), exchange=xchg, confirm=True).result()
And voila, we're done here!
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment