Stomping with Python and ActiveMQ (Stomp Framework)

python-stomping is a simple Stomp framework I wrote which makes creating stomp services in Python easy.

  1. Install requirements

    $ sudo yum install python-twisted python-stomper
    
  2. Checkout stomping

    $ svn export http://silassewell.googlecode.com/svn/trunk/projects/python-stomping python-stomping
    $ cd python-stomping
    
  3. Update the example.py file to use your host, port, username and password ActiveMQ/Stomp broker settings

    from stomping import Stomping, route
    
    class MyStomping(Stomping):
    
    def init(self):
        self.send('/queue/test1', 'init test1')
        self.send('/queue/test2', 'init test2')
    
    @route('/queue/test1')
    def a_test(self, message):
        print 'a_test: %s' % message['body']
    
    @route('/queue/test1')
    @route('/queue/test2')
    def b_test(self, message):
        print 'b_test: %s' % message['body']
    
    if __name__ == '__main__':
        stomp = MyStomping(host='127.0.0.1', port=61613, username='guest', password='guest')
        stomp.run()
    
  4. Run example.py (Ctrl+c to quit)

    $ python example.py 
    a_test: init test1
    b_test: init test1
    b_test: init test2
    

NOTE: python-stomping is just a light wrapper around Twisted and stomper and is based on an example provided in the stomper code.