Welcome to Pikacon’s documentation!


Pikacon is a helper library which will reduce the amount of boilerplate your software needs when it is using pika for creating connection to broker and declaring exchanges and queues.

Pikacon provides helper class (ClassName) which can be imported to your program. Class takes a path to ini-style config file as a parameter and creates connection, exchanges, queues and bindings automatically from there. All you need to provide is a proper config.



Pikacon uses Pythons ConfigParser to get config for connection, exchanges and queues.


Broker is configured as in above example. Section name is broker and options are regular pika parameters for broker. If you want to configure ssl_options create new section for those and refer that section name in broker options. Eg.:

ssl = True
ssl_options = my_ssl_options



Section name for exchange consists of two parts divided by ‘:’. First part is ‘exchange’ and second part is the name of the exchange. Eg.:


The actual options below exchange section are normal key = value parameters which are used in pika.


The name of the binding section consists three parts divided by ‘:’. First part is always ‘binding’. Second part is the name of the queue we’re binding. Third part is name of the exchange where we’re binding the queue. Eg.:


The actual options below binding section are normal key = value parameters which are used in pika.

Processing order

Pikacon’s processing order is following:

  1. Connection
  2. Channel
  3. Exchanges
  4. Queues
  5. Bindings

Complete configuration example

host = localhost
port = 5672
username = guest
password = guest
virtual_host = /
heartbeat = 60

type = direct
durable = False
auto_delete = True

durable = True
exclusive = False

durable = False
exclusive = False

durable = True
exclusive = False
arguments = queue:testqueue3:arguments

durable = True
exclusive = False

x-message-ttl = 1800000
x-dead-letter-exchange = exchangename
x-dead-letter-routing-key = key4

routing_key = key1

routing_key = key2

routing_key = key3

routing_key = key4

Above example configures connection to broker at localhost. It defines one direct exchange called exchangename and four queues called testqueue1, testqueue2, testqueue3 and testqueue4. Testqueue3 has extra arguments which define dead letter exchange. All queues are bound to our only exchange with routingkeys key1, key2, key3 and key4.

Pikacon usage example

from pikacon.pikacon import BrokerConnection

class PikaconExample(object):

    def __init__(self):
        self.broker = BrokerConnection(

    def broker_ready_callback(self):
        """Do something with the broker."""

Yes. Above is full example of working code which sets up connections, channels, exchanges, queues and bindings assuming they have been configured in /path/to/congfig.cfg. You can start using self.broker as you would use pika.

Source code

Pikacon’s source code and issue tracker is at Github. Fork or send a ticket if you have troube with it.