Eventhub Reading Data As List In Python
I want to use Azure Eventhub as a middleware messaging queue. I am basically sending simulated data in list formats and receiving it in string format now. As you can see Here, the
Solution 1:
The fixed code following worked:
logger = logging.getLogger("azure")
ADDRESS = ""
USER = "RootManageSharedAccessKey"
KEY = ""try:
ifnot ADDRESS:
raise ValueError("No EventHubs URL supplied.")
# Create Event Hubs client
client = EventHubClient(ADDRESS, debug=False, username=USER, password=KEY)
sender = client.add_sender(partition="0")
client.run()
forging2 = lambda x: (np.exp(-(0.1*x-6)**2+3) + np.exp(-(0.1*x-4)**2+4))*1.4
x_value = np.arange(100)
try:
start_time = time.time()
for i inrange(100000):
y_value1 = forging1(x_value) + np.random.normal(0,1,len(x_value))*3
y_value1 = np.asarray(y_value1)
print("Sending message: {}, {}".format(i, y_value1))
message = "{}".format(y_value1)
sender.send(EventData(message))
time.sleep(0.35)
except:
raisefinally:
end_time = time.time()
client.stop()
run_time = end_time - start_time
logger.info("Runtime: {} seconds".format(run_time))
except KeyboardInterrupt:
pass
In this way, I was able to receive the messages without "messages" in it.
Post a Comment for "Eventhub Reading Data As List In Python"