Skip to content

Instantly share code, notes, and snippets.

@tomconte
Last active February 15, 2018 08:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tomconte/c94af7efeccb2a274b82 to your computer and use it in GitHub Desktop.
Save tomconte/c94af7efeccb2a274b82 to your computer and use it in GitHub Desktop.
Send messages to an Azure Event Hub using the Apache Qpid Proton AMQP library.
#!/usr/bin/python
# Send messages to an Azure Event Hub using the Apache Qpid Proton AMQP library.
import sys
import commands
from proton import *
# Event Hub address & credentials
# amqps://<keyname>:<key>@<namespace>.servicebus.windows.net/<eventhubname>
# You can find <keyname> and <key> in your Service Bus connection information
# <key> needs to be URL-encoded
# <namespace> is your SB top-level namespace
# <eventhubname> is the name of your Event Hub
address = "amqps://send:xxxx@demohub.servicebus.windows.net/yun";
# Create Proton objects
messenger = Messenger()
# Create AMQP message
message = Message()
message.body = sys.argv[1]
message.address = address
messenger.put(message)
messenger.send()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment