Guest User

Untitled

a guest
Jan 26th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. from stompy import stomp
  2. import json
  3.  
  4.  
  5. s = stomp.Stomp(amq_ip, amq_port)
  6.  
  7. try:
  8. s.connect(username=amq_user, password=amq_pass)
  9. s.subscribe({'destination': '%s' % amq_queue, 'ack': 'client'})
  10. except Exception as e:
  11. print "ActiveMQ errorn %s" % e
  12.  
  13. while True:
  14. try:
  15. frame = s.receive_frame()
  16. body = json.loads(frame.body)
  17.  
  18. # это сообщение для меня?
  19. if body["interested_atr_in_msg"] == "interested_value_of_attr_in_msg":
  20. print "Its for me. I receive it"
  21. # Это сообщение для меня. Я его приму и обработаю
  22. s.ack(frame)
  23. else:
  24. # Это сообщение предназначено для кого-то другого и мне не подходит
  25. print "Its not for me"
  26. except Exception as e:
  27. print e
Add Comment
Please, Sign In to add comment