The following example shows how to use asyncapi-python
package to create publisher-subscriber communications.
-
A working
amqp
brokerThis example assumes that it will be accessible by
amqp://guest:guest@localhost
. If this is not true, setAMQP_URI
envvar accordingly
-
cd
into this directory -
Create python virtual environment and activate it.
Alternatively, run
make venv install
.python3 -m venv .venv . .venv/bin/activate
-
Generate client and server modules.
Alternatively, run
make generate
.asyncapi-python-codegen spec/publisher.asyncapi.yaml publisher --force asyncapi-python-codegen spec/subscriber.asyncapi.yaml subscriber --force
-
Run subscriber, and then publisher. This requires two terminals.
.venv/bin/python main-subscriber.py
.venv/bin/python main-publisher.py