Skip to content
Merged
Show file tree
Hide file tree
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
11 changes: 11 additions & 0 deletions sdk/eventhub/azure-eventhub/azure/eventhub/_producer_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,12 @@ def send_batch(self, event_data_batch, **kwargs):
"""
partition_id = kwargs.get("partition_id")
partition_key = kwargs.get("partition_key")

if partition_key and not isinstance(partition_key, str):
_LOGGER.info("WARNING: Please DO NOT pass a partition_key of non-string type to the send_batch method."
Comment thread
yunhaoling marked this conversation as resolved.
Outdated
"The Event Hub service ignores partition_key of non-string type, "
"in which case events will be assigned to all partitions using round-robin.")

if isinstance(event_data_batch, EventDataBatch):
if partition_id or partition_key:
raise TypeError("partition_id and partition_key should be None when sending an EventDataBatch "
Expand Down Expand Up @@ -306,6 +312,11 @@ def create_batch(self, **kwargs):
partition_id = kwargs.get("partition_id", None)
partition_key = kwargs.get("partition_key", None)

if partition_key and not isinstance(partition_key, str):
Comment thread
yunhaoling marked this conversation as resolved.
Outdated
_LOGGER.info("WARNING: Please DO NOT pass a partition_key of non-string type to the create_batch method."
"The Event Hub service ignores partition_key of non-string type, "
"in which case events will be assigned to all partitions using round-robin.")

if max_size_in_bytes and max_size_in_bytes > self._max_message_size_on_link:
raise ValueError(
"Max message size: {} is too large, acceptable max batch size is: {} bytes.".format(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,12 @@ async def send_batch(
"""
partition_id = kwargs.get("partition_id")
partition_key = kwargs.get("partition_key")

if partition_key and not isinstance(partition_key, str):
_LOGGER.info("WARNING: Please DO NOT pass a partition_key of non-string type to the send_batch method."
"The Event Hub service ignores partition_key of non-string type, "
"in which case events will be assigned to all partitions using round-robin.")

if isinstance(event_data_batch, EventDataBatch):
if partition_id or partition_key:
raise TypeError("partition_id and partition_key should be None when sending an EventDataBatch "
Expand Down Expand Up @@ -337,6 +343,11 @@ async def create_batch(
if not self._max_message_size_on_link:
await self._get_max_mesage_size()

if partition_key and not isinstance(partition_key, str):
_LOGGER.info("WARNING: Please DO NOT pass a partition_key of non-string type to the create_batch method."
"The Event Hub service ignores partition_key of non-string type, "
"in which case events will be assigned to all partitions using round-robin.")

if max_size_in_bytes and max_size_in_bytes > self._max_message_size_on_link:
raise ValueError(
"Max message size: {} is too large, acceptable max batch size is: {} bytes.".format(
Expand Down