client.py 617 B

12345678910111213141516171819
  1. from stompest.config import StompConfig
  2. from stompest.protocol import StompSpec
  3. from stompest.sync import Stomp
  4. CONFIG = StompConfig('tcp://localhost:61613', version=StompSpec.VERSION_1_1)
  5. QUEUE = '/queue/test'
  6. if __name__ == '__main__':
  7. client = Stomp(CONFIG)
  8. client.connect(heartBeats=(0, 10000))
  9. client.subscribe(QUEUE, {StompSpec.ID_HEADER: 1, StompSpec.ACK_HEADER: StompSpec.ACK_CLIENT_INDIVIDUAL})
  10. client.send(QUEUE, 'test message 1')
  11. client.send(QUEUE, 'test message 2')
  12. while True:
  13. frame = client.receiveFrame()
  14. print 'Got %s' % frame.info()
  15. client.ack(frame)
  16. client.disconnect()