STOMPify is a implementation of STOMP protocol on top of twisted.
from twisted.internet import reactor, defer
from stompify import proto, dispatcher
class MyDispatcher(dispatcher.StompClient):
def on_message(self, frame, proto):
print "message received: %s" % frame
self.disconnect('eof')
def on_receipt(self, frame, proto):
print "receipt received: %s" % frame
if frame.getHeader('receipt-id') == 'eof':
from twisted.internet import reactor
reactor.callLater(2, self._halt)
def _halt(self):
print "eof eof eof"
def _started(dispatcher):
dispatcher.subscribe('/queue/temp')
dispatcher.send(body="hello world", destination='/queue/temp')
start_defer = defer.Deferred()
f = proto.StompClientFactory()
f.setDispatcher(MyDispatcher, start_defer)
start_defer.addCallback(_started)
reactor.connectTCP('localhost', 61613, f)
reactor.run()
- Follow twisted coding style and standard
- Make it possible to embed this implementation in any twisted application
python setup.py install (or develop for development)
There are few examples of NodeSet framework usage:
- stomp.tac - twistd .tac file for STOMP server
- stomp-client.tac - twisted .tac file for STOMP client
- stom_c.py - python script with twisted reactor.run()