I'm sending a JSON dump to the event hub using my python app. My connection string is of the form
connection_string="Endpoint=sb://xyz.servicebus.windows.net/;SharedAccessKeyName=abc;SharedAccessKey=pqr"
I get the following response
Token put complete with result: 0, status: 202, description: b'Accepted', connection:xxxxxxxxx
But I don't see the data in the eventhub. I don't get any error as well. My question is the event being sent? If the event is successfully sent, should we not get a response code 200?
My code is from this link
from azure.eventhub import EventHubProducerClient, EventData
def send_event_data_batch(producer, data):
# Without specifying partition_id or partition_key
# the events will be distributed to available partitions via round-robin.
event_data_batch = producer.create_batch()
event_data_batch.add(EventData(data))
try:
producer.send_batch(event_data_batch)
except Exception as exp:
_LOG.info(type(exp).__name__)
_LOG.info(exp.args)
producer.close()
def send_data_to_event_hub(data):
producer = EventHubProducerClient.from_connection_string(
conn_str=connection_string,
eventhub_name="EVENT HUB NAME" )
with producer:
send_event_data_batch(producer, data)
producer.close()
The send() method returns nothing ( None
) if it's successful, or raises an error of family EventHubError
if it's not successful. The "Token put complete with result: 0, status: 202, description: b'Accepted', connection:xxxxxxxxx" is logging information of building connections.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.