Last active
December 15, 2015 12:28
-
-
Save gmr/5259929 to your computer and use it in GitHub Desktop.
A comparison of publishing with rmqid, amqplib and pika
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import rmqid | |
rmqid.publish('amqp://guest:guest@localhost:5672/%2f', | |
exchange='test', | |
routing_key='example', | |
body='Test message') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import rmqid | |
with rmqid.Connection('amqp://guest:guest@localhost:5672/%2f') as connection: | |
with conn.channel() as channel: | |
message = rmqid.Message(channel, 'Test message') | |
message.publish('test', 'test-routing-key') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pika | |
parameters = pika.URLParameters('amqp://guest:guest@localhost:5672/%2F') | |
connection = pika.BlockingConnection(parameters) | |
channel = connection.channel() | |
channel.basic_publish('test', | |
'example', | |
'Test message') | |
connection.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import amqplib.client_0_8 as amqp | |
conn = amqp.Connection('localhost:5672', 'guest', 'guest', virtual_host='/') | |
ch = conn.channel() | |
msg = amqp.Message('Test message') | |
ch.basic_publish(msg, 'test', 'example') | |
ch.close() | |
conn.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment