Skip to content

Instantly share code, notes, and snippets.

@shivamMg
Created February 10, 2020 15:40
Show Gist options
  • Save shivamMg/2a24668b3c51bd94fe3c06f25c10a97d to your computer and use it in GitHub Desktop.
Save shivamMg/2a24668b3c51bd94fe3c06f25c10a97d to your computer and use it in GitHub Desktop.
from librabbitmq import Connection
conn = Connection(
host='<host>:443',
userid='<userid>',
password='<password>',
virtual_host='/',
ssl={
'server_hostname': '<host>'
},
)
channel = conn.channel()
channel.exchange_declare(exchange='exch')
result = channel.queue_declare(queue='')
channel.queue_bind(queue=result.queue, exchange='exch', routing_key='')
channel.basic_publish(exchange='exch', routing_key='', body='body msg')
conn.close()
from librabbitmq import Connection
conn = Connection(
host='<host>:443',
userid='<userid>',
password='<password>',
virtual_host='/',
ssl={
'server_hostname': '<host>'
},
)
channel = conn.channel()
channel.exchange_declare(exchange='exch')
result = channel.queue_declare(queue='')
channel.queue_bind(queue=result.queue, exchange='exch', routing_key='')
def callback(message):
print("Body:'%s', Properties:'%s', DeliveryInfo:'%s'" % (
message.body.tobytes(), message.properties, message.delivery_info))
channel.basic_consume(queue=result.queue, callback=callback)
print 'loop'
conn.drain_events()
conn.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment