Skip to content

Instantly share code, notes, and snippets.

@shawonis08
Created September 2, 2021 18:06
Show Gist options
  • Save shawonis08/142dcff4f053a800a7366277bfebdb13 to your computer and use it in GitHub Desktop.
Save shawonis08/142dcff4f053a800a7366277bfebdb13 to your computer and use it in GitHub Desktop.
rabbitmq remote server connection with python
from pika import PlainCredentials, ConnectionParameters, BlockingConnection
USERNAME = ''
PASSWORD = ''
IPADDRESS = ''
PORT = 5672
credentials = PlainCredentials(USERNAME, PASSWORD)
parameters = ConnectionParameters(IPADDRESS,
PORT,
'/',
credentials)
connection = BlockingConnection(parameters)
channel = connection.channel()
channel.queue_declare(queue='hello')
channel.basic_publish(exchange='',
routing_key='hell',
body='HEllO World!')
print(" Hello vhost")
connection.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment