-
-
Save gdyrrahitis/c763fae2978370f05f061c8089eb1db6 to your computer and use it in GitHub Desktop.
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 rabbitpy | |
def publish(channel): | |
body = "Hello world!" | |
message = rabbitpy.Message(channel, body, {'content_type': 'text/plain'}) | |
delivered = message.publish('rabbitpy-tests', 'ha-routing-key', mandatory=True) | |
if delivered: | |
print('Message delivered') | |
else: | |
print('Delivery failed') | |
if __name__ == '__main__': | |
# I have created a new admin user "test" with password "test" | |
# The below is the IP of the proxy | |
url = "amqp://test:test@192.168.0.221:5672/" | |
try: | |
with rabbitpy.Connection(url) as connection: | |
with connection.channel() as channel: | |
# enabled publisher confirms | |
channel.enable_publisher_confirms() | |
publish(channel) | |
except rabbitpy.exceptions.MessageReturnedException as ex: | |
print "Failed to publish %s" % ex | |
except KeyboardInterrupt: | |
print('exiting...') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment