Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
14 changes: 14 additions & 0 deletions sdk/eventhub/azure-eventhubs/HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,20 @@
- `on_error(partition_context, exception` called when errors occur.
- `on_partition_initialize(partition_context)` called when a partition consumer is opened.
- `on_partition_close(partition_context, reason)` called when a partition consumer is closed.
- Some modules and classes that were importable from several different places have been removed:
- `azure.eventhub.common` has been removed. Import from `azure.eventhub` instead.
- `azure.eventhub.client_abstract` has been removed. Use `azure.eventhub.EventHubProducerClient` or `azure.eventhub.EventHubConsumerClient` instead.
- `azure.eventhub.client` has been removed. Use `azure.eventhub.EventHubProducerClient` or `azure.eventhub.EventHubConsumerClient` instead.
- `azure.eventhub.producer` has been removed. Use `azure.eventhub.EventHubProducerClient` instead.
- `azure.eventhub.consumer` has been removed. Use `azure.eventhub.EventHubConsumerClient` instead.
- `azure.eventhub.aio.client_async` has been removed. Use `azure.eventhub.aio.EventHubProducerClient` or `azure.eventhub.aio.EventHubConsumerClient` instead.
- `azure.eventhub.aio.producer_async` has been removed. Use `azure.eventhub.aio.EventHubProducerClient` instead.
- `azure.eventhub.aio.consumer_async` has been removed. Use `azure.eventhub.aio.EventHubConsumerClient` instead.
- `azure.eventhub.aio.event_processor.event_processor` has been removed. Use `azure.eventhub.aio.EventHubConsumerClient` instead.
- `azure.eventhub.aio.event_processor.partition_processor` has been removed. Use callback methods instead.
- `azure.eventhub.aio.event_processor.partition_manager` has been removed. Import from `azure.eventhub.aio` instead.
- `azure.eventhub.aio.event_processor.partition_context` has been removed. Import from `azure.eventhub.aio` instead.
- `azure.eventhub.aio.event_processor.sample_partition_manager` has been removed.

**Bug fixes**

Expand Down
2 changes: 1 addition & 1 deletion sdk/eventhub/azure-eventhubs/azure/eventhub/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ def body_as_str(self, encoding='UTF-8'):

:param encoding: The encoding to use for decoding message data.
Default is 'UTF-8'
:rtype: str or unicode
:rtype: str
"""
data = self.body
try:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,16 @@ async def receive(client):
await client.receive(on_events=on_events,
consumer_group="$default")
except KeyboardInterrupt:
client.close()
await client.close()


if __name__ == '__main__':
loop = asyncio.get_event_loop()
async def main():
client = EventHubConsumerClient.from_connection_string(
CONNECTION_STR,
)
try:
loop.run_until_complete(receive(client))
except KeyboardInterrupt:
pass
finally:
loop.run_until_complete(client.close())
loop.stop()
async with client:
await receive(client)

if __name__ == '__main__':
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,20 @@ async def receive(client):
try:
await client.receive(on_events=on_events,
consumer_group="$default",
partition_id='0')
partition_id='0',
track_last_enqueued_event_properties=True)
except KeyboardInterrupt:
client.close()
await client.close()


if __name__ == '__main__':
loop = asyncio.get_event_loop()
async def main():
client = EventHubConsumerClient.from_connection_string(
CONNECTION_STR,
)
try:
loop.run_until_complete(receive(client))
except KeyboardInterrupt:
pass
finally:
loop.run_until_complete(client.close())
loop.stop()
async with client:
await receive(client)


if __name__ == '__main__':
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,20 @@ async def receive(client):
# With specified partition_id, load-balance will be disabled
# await client.receive(event_handler=event_handler, consumer_group="$default", partition_id = '0'))
except KeyboardInterrupt:
client.close()
await client.close()


if __name__ == '__main__':
loop = asyncio.get_event_loop()
async def main():
container_client = ContainerClient.from_connection_string(STORAGE_CONNECTION_STR, "eventprocessor")
partition_manager = BlobPartitionManager(container_client)
client = EventHubConsumerClient.from_connection_string(
CONNECTION_STR,
partition_manager=partition_manager, # For load balancing and checkpoint. Leave None for no load balancing
)
try:
loop.run_until_complete(receive(client))
except KeyboardInterrupt:
pass
finally:
loop.run_until_complete(client.close())
loop.stop()
async with client:
await receive(client)


if __name__ == '__main__':
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,7 @@ def example_eventhub_sync_send_and_receive():

event_data = EventData("String data")
event_data = EventData(b"Bytes data")
event_data = EventData([b"A", b"B", b"C"])

list_data = ['Message {}'.format(i) for i in range(10)]
event_data = EventData(body=list_data)
# [END create_event_data]

# [START eventhub_producer_client_create_batch_sync]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import time
import pytest
import threading
import sys
from azure.eventhub import EventData
from azure.eventhub import EventHubConsumerClient
from azure.eventhub._eventprocessor.local_partition_manager import InMemoryPartitionManager
Expand Down Expand Up @@ -54,6 +55,9 @@ def on_events(partition_context, events):

@pytest.mark.liveTest
def test_receive_load_balancing(connstr_senders):
if sys.platform.startswith('darwin'):
pytest.skip("Skipping on OSX - test code using multiple threads. Sometimes OSX aborts python process")

connection_str, senders = connstr_senders
pm = InMemoryPartitionManager()
client1 = EventHubConsumerClient.from_connection_string(
Expand Down