Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions sdk/eventhub/azure-eventhubs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ from azure.eventhub import EventHubConsumerClient

connection_str = '<< CONNECTION STRING FOR THE EVENT HUBS NAMESPACE >>'
event_hub_path = '<< NAME OF THE EVENT HUB >>'
consumer_client = EventHubConsumerClient.from_connection_string(connection_str, event_hub_path)
consumer_client = EventHubConsumerClient.from_connection_string(connection_str, event_hub_path=event_hub_path)

```

Expand Down Expand Up @@ -128,7 +128,7 @@ from azure.eventhub import EventHubConsumerClient

connection_str = '<< CONNECTION STRING FOR THE EVENT HUBS NAMESPACE >>'
event_hub_path = '<< NAME OF THE EVENT HUB >>'
client = EventHubConsumerClient.from_connection_string(connection_str, event_hub_path)
client = EventHubConsumerClient.from_connection_string(connection_str, event_hub_path=event_hub_path)
partition_ids = client.get_partition_ids()
```

Expand All @@ -143,7 +143,7 @@ from azure.eventhub import EventHubProducerClient, EventData

connection_str = '<< CONNECTION STRING FOR THE EVENT HUBS NAMESPACE >>'
event_hub_path = '<< NAME OF THE EVENT HUB >>'
client = EventHubProducerClient.from_connection_string(connection_str, event_hub_path)
client = EventHubProducerClient.from_connection_string(connection_str, event_hub_path=event_hub_path)

try:
event_list = []
Expand All @@ -167,7 +167,7 @@ from azure.eventhub import EventHubProducerClient, EventData
try:
connection_str = '<< CONNECTION STRING FOR THE EVENT HUBS NAMESPACE >>'
event_hub_path = '<< NAME OF THE EVENT HUB >>'
client = EventHubProducerClient.from_connection_string(connection_str, event_hub_path)
client = EventHubProducerClient.from_connection_string(connection_str, event_hub_path=event_hub_path)

event_data_batch = client.create_batch(max_size=10000)
can_add = True
Expand Down Expand Up @@ -195,7 +195,7 @@ from azure.eventhub import EventHubConsumerClient

connection_str = '<< CONNECTION STRING FOR THE EVENT HUBS NAMESPACE >>'
event_hub_path = '<< NAME OF THE EVENT HUB >>'
client = EventHubConsumerClient.from_connection_string(connection_str, event_hub_path)
client = EventHubConsumerClient.from_connection_string(connection_str, event_hub_path=event_hub_path)

logger = logging.getLogger("azure.eventhub")

Expand Down Expand Up @@ -224,7 +224,7 @@ from azure.eventhub import EventData

connection_str = '<< CONNECTION STRING FOR THE EVENT HUBS NAMESPACE >>'
event_hub_path = '<< NAME OF THE EVENT HUB >>'
client = EventHubProducerClient.from_connection_string(connection_str, event_hub_path)
client = EventHubProducerClient.from_connection_string(connection_str, event_hub_path=event_hub_path)

try:
event_list = []
Expand All @@ -251,7 +251,7 @@ from azure.eventhub import EventData
try:
connection_str = '<< CONNECTION STRING FOR THE EVENT HUBS NAMESPACE >>'
event_hub_path = '<< NAME OF THE EVENT HUB >>'
client = EventHubProducerClient.from_connection_string(connection_str, event_hub_path)
client = EventHubProducerClient.from_connection_string(connection_str, event_hub_path=event_hub_path)

event_data_batch = await client.create_batch(max_size=10000)
can_add = True
Expand Down Expand Up @@ -279,7 +279,7 @@ from azure.eventhub.aio import EventHubConsumerClient

connection_str = '<< CONNECTION STRING FOR THE EVENT HUBS NAMESPACE >>'
event_hub_path = '<< NAME OF THE EVENT HUB >>'
client = EventHubConsumerClient.from_connection_string(connection_str, event_hub_path)
client = EventHubConsumerClient.from_connection_string(connection_str, event_hub_path=event_hub_path)

logger = logging.getLogger("azure.eventhub")

Expand Down Expand Up @@ -330,6 +330,7 @@ from azure.eventhub.extensions.checkpointstoreblobaio import BlobPartitionManage
RECEIVE_TIMEOUT = 5 # timeout in seconds for a receiving operation. 0 or None means no timeout
RETRY_TOTAL = 3 # max number of retries for receive operations within the receive timeout. Actual number of retries clould be less if RECEIVE_TIMEOUT is too small
connection_str = '<< CONNECTION STRING FOR THE EVENT HUBS NAMESPACE >>'
event_hub_path = '<< NAME OF THE EVENT HUB >>'
storage_connection_str = '<< CONNECTION STRING FOR THE STORAGE >>'
blob_name_str = '<<STRING FOR THE BLOB NAME>>'

Expand All @@ -345,7 +346,7 @@ if __name__ == '__main__':
loop = asyncio.get_event_loop()
container_client = ContainerClient.from_connection_string(storage_connection_str, blob_name_str)
partition_manager = BlobPartitionManager(container_client=container_client)
client = EventHubConsumerClient.from_connection_string(connection_str, partition_manager=partition_manager, receive_timeout=RECEIVE_TIMEOUT, retry_total=RETRY_TOTAL)
client = EventHubConsumerClient.from_connection_string(connection_str, event_hub_path=event_hub_path, partition_manager=partition_manager, receive_timeout=RECEIVE_TIMEOUT, retry_total=RETRY_TOTAL)
try:
loop.run_until_complete(client.receive(process_events, "$default"))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we please update this sample in the same way as @lmazuel commented on the previous PR?
If I recall correctly, it was something like:

async def main():
    container_client = ContainerClient.from_connection_string(storage_connection_str, blob_name_str)
    partition_manager = BlobPartitionManager(container_client=container_client)
     client = EventHubConsumerClient.from_connection_string(connection_str, event_hub_path=event_hub_path, partition_manager=partition_manager, receive_timeout=RECEIVE_TIMEOUT, retry_total=RETRY_TOTAL)
    await client.receive(process_events, "$default")
    await client.close()

if __name__ == '__main__':
    loop = asyncio.get_event_loop()
    try:
        loop.run_until_complete(main())
    finally:
        loop.stop()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated the sample in readme

except KeyboardInterrupt:
Expand Down