mirror of
https://git.kotyczka.ch/developers/django.git
synced 2025-04-05 23:35:08 +02:00
23 lines
1.3 KiB
Python
Executable File
23 lines
1.3 KiB
Python
Executable File
import pika
|
|
##import amqp
|
|
import config
|
|
#declaring the credentials needed for connection like host, port, username, password, exchange etc
|
|
credentials= pika.PlainCredentials(username= config.username, password= config.password)
|
|
connection= pika.BlockingConnection(pika.ConnectionParameters(host='localhost', port=61616, credentials= credentials))
|
|
channel = connection.channel()
|
|
channel.exchange_declare(exchange='pydev', durable=True, exchange_type='topic')
|
|
channel.queue_declare(queue= 'A')
|
|
channel.queue_bind(exchange='pydev', queue='A', routing_key='A')
|
|
channel.queue_declare(queue= 'B')
|
|
channel.queue_bind(exchange='pydev', queue='B', routing_key='B')
|
|
channel.queue_declare(queue= 'C')
|
|
channel.queue_bind(exchange='pydev', queue='C', routing_key='C')
|
|
#messaging to queue named C
|
|
message_spec= 'Only this channel can see this message'
|
|
message_all= 'Welcome to python queue handling...'
|
|
channel.basic_publish(exchange='pydev', routing_key='A', body= message_all)
|
|
channel.basic_publish(exchange='pydev', routing_key='B', body= message_all)
|
|
channel.basic_publish(exchange='pydev', routing_key='C', body= message_all)
|
|
channel.basic_publish(exchange='pydev', routing_key='B', body= message_spec)
|
|
channel.basic_publish(exchange='pydev', routing_key='C', body= message_spec)
|
|
channel.close() |