Guest User

Untitled

a guest
Jul 17th, 2020
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.70 KB | None | 0 0
  1. import time
  2.  
  3. import proton
  4. from proton import Message
  5. from proton.handlers import MessagingHandler
  6. from proton.reactor import Container
  7.  
  8. from proton.utils import BlockingConnection
  9.  
  10. def AMQPsend(broker_url):
  11.     host = broker_url.split("/",1)[0]
  12.     topic = broker_url.split("/",1)[1]
  13.  
  14.     try:
  15.         amqp_blk_conn = BlockingConnection(host,heartbeat=1,timeout=60)
  16.     except:
  17.         print("Fatal error when connecting to: "+ host + "/" + topic)
  18.         exit(1)
  19.  
  20.     sender=amqp_blk_conn.create_sender(topic)
  21.  
  22.     while True:
  23.         time.sleep(1)
  24.         req = Message(body="HelloWorld!")
  25.         sender.send(req);
  26.  
  27. AMQPsend("192.168.1.2:5672/topic://test.activemq.topic.001")
Advertisement
Add Comment
Please, Sign In to add comment