RMQ Consumer (Python)

Make sure to adjust the following fields as described on documentation : * <UserName> = username * <Password> = password * <HostName> = OS - InPlay: inplay-rmq.lsports.eu / PreMatch: prematch-rmq.lsports.eu STM - InPlay: stm-inplay.lsports.eu / PreMatch: stm-prematch.lsports.eu * <VirtualHost> = OS = VirtualHost = "Customers" STM = VirtualHost = "StmPreMatch" / VirtualHost = "StmInPlay" * <PackageID> = should be a number between “_“ for example _100_

import pika

connection = pika.BlockingConnection(
pika.ConnectionParameters(
host='HostName',
port=5672,
virtual_host='VHost',
credentials=pika.PlainCredentials('<UserName>', '<Password>')
)
)
channel = connection.channel()

def callback(ch, method, properties, body):
print("Received message: %r" % body)

channel.basic_consume(queue='_<package_id>_', on_message_callback=callback, auto_ack=True)

print("Waiting for messages...")
channel.start_consuming()

Last updated