http://www.rabbitmq.com/tutorials/ - code taken from here.