Python3 and rabbitmq

Im using rabbitmq in some of my python apps. Here is a small guide to get pyton3 to send and recive data from rabbitmq


I uses the code from

And read some guide from from 2009 !!!!


Get the pip you need to connect

sudo pip3 install amqp



My python code for sending and reciving


#!/usr/bin/env python
from amqplib import client_0_8 as amqp
import time

conn = amqp.Connection(host=" ", userid="guest",
password="guest", virtual_host="/", insist=False)
chan =

#Setup que
chan.queue_declare(queue="work", durable=True,
exclusive=False, auto_delete=False)
chan.exchange_declare(exchange="sorting_room", type="direct", durable=True,
chan.queue_bind(queue="work", exchange="sorting_room",

#Send messages
send = amqp.Message("Test message!")["delivery_mode"] = 2

#Get data runns and lissen for the loop
def recv_callback(msg):
    print('Received: ' + msg.body + ' from channel #' + str(

chan.basic_consume(queue='work', no_ack=True, callback=recv_callback, consumer_tag="testtag")
while True: