bra_fsn_hu

activemq virtualtopic STOMP send

Nov 5th, 2013
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.39 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. import logging
  4. logging.basicConfig()
  5. #logging.getLogger().setLevel(logging.DEBUG)
  6. import stomp
  7. import random
  8. import os
  9. import time
  10.  
  11. random.seed()
  12.  
  13. conn = stomp.Connection(host_and_ports=[('localhost',5000)],
  14.                         use_ssl=True,
  15.                         ssl_key_file = '/usr/local/etc/stunnel/radius-producer.key',
  16.                         ssl_cert_file = '/usr/local/etc/stunnel/radius-producer.pem',
  17.                         )
  18. conn.start()
  19. conn.connect()
  20.  
  21. status_types=['START','INTERIM_UPDATE','STOP']
  22.  
  23. prevcnt=0
  24. prevreport=time.time()
  25. cnt=0
  26. start=time.time()
  27. for i in range(20000):
  28.     reclen=random.randint(160,300)
  29.     system='wired'
  30.     status_type=status_types[i%3]
  31.     realm='online'
  32.     data=os.urandom(reclen)
  33.     conn.send(data,
  34.               destination='/topic/VirtualTopic.radius',
  35.               headers={
  36.                        'content-length':reclen,
  37.                        'persistent':'true',
  38.                        'Xsystem':system,
  39.                        'Xstatustype':status_type,
  40.                        'Xrealm':realm,
  41.                      },
  42.               )
  43.     if status_type=='STOP' or status_type=='INTERIM_UPDATE':
  44.         cnt+=1
  45.     if time.time()-prevreport>=1:
  46.         print time.time()-start,cnt-prevcnt,cnt
  47.         prevcnt=cnt
  48.         prevreport=time.time()
  49. print time.time()-start,cnt-prevcnt,cnt
Advertisement
Add Comment
Please, Sign In to add comment