I've started work on txsrv, a Python library that aims to make developing message-based services in Twisted easy.
The code is still pretty rough, but might be of interest to someone hacking on AMQP-based Twisted services.
Sample Usage
Create a new service and change to the project directory.
$ txsrv create mytest
$ cd mytest
Edit the mytest.conf file so that the spec_file option is valid.
[connection:amqp]
type = amqp
host = localhost
port = 5672
vhost = /
user = guest
password = guest
spec_file = /usr/share/amqp/amqp.0-8.xml
[handler:hello]
connection = amqp
exchange = hello
routing_key = default
Edit the mytest.py file so that it prints the message body twice.
import txsrv
class Service(txsrv.Service):
@txsrv.handler('hello')
def hello(self, message):
print message.body * 2
class ServiceMaker(txsrv.ServiceMaker):
tapname = 'mytest'
description = 'A mytest txsrv example.'
service_type = Service
Start the mytest service and send a message to the hello exchange.
$ twistd -n mytest -c mytest.conf
2010-09-12 00:41:10-0400 [-] Log opened.
2010-09-12 00:41:10-0400 [-] twistd 10.1.0 (/usr/bin/python 2.6.4) starting up.
2010-09-12 00:41:10-0400 [-] reactor class: twisted.internet.selectreactor.SelectReactor.
2010-09-12 00:41:10-0400 [-] Starting factory <txsrv.protocol.amqp.AmqpFactory instance at 0x2cce950>
2010-09-12 00:41:10-0400 [AmqpProtocol,client] hellohello
Licensing information is available on the about page, for additional questions or comments feel free to contact me.