Skip to content
Snippets Groups Projects
tutorial.md 878 B

Tutorial

If you want to connect to an AMQP broker, you need:

  • it's address (and port)
  • login and password
  • name of the virtual host

An idea of a heartbeat interval would be good, but you can do without. Since CoolAMQP will support clusters in the future, you should define the nodes first. You can do it using NodeDefinition. See NodeDefinition's documentation for alternative ways to do this, but here we will use the AMQP connection string.

from coolamqp.objects import NodeDefinition

node = NodeDefinition('amqp://user@password:host/vhost')

Cluster instances are used to interface with the cluster (or a single broker). It accepts a list of nodes:

from coolamqp.clustering import Cluster
cluster = Cluster([node])
cluster.start(wait=True)

wait=True will block until connection is completed. After this, you can use other methods.