Azure / Azure/azure-sdk-for-python

Allow custom `owner_id` in `azure-eventhub` EventProcessor's `receive`/`receive_batch`

オープン
#40,949 コメント 2 件 リアクション 1 件 担当者 3 名 GitHub で見る

@l0lawrence がすでに取り組んでいます。

2025年5月7日 から。

Client customer-reported Event Hubs feature-request Messaging needs-team-attention
主要言語
Python
スター
5.6k
フォーク
3.4k
平均マージ
2日 2時間
マージ済み PR(30日)
213

説明

Is your feature request related to a problem? Please describe.
Currently, the EventProcessor in azure-eventhub auto-generates an owner_id using str(uuid.uuid4()) when calling receive/receive_batch. This becomes problematic in environments with frequent pod/worker restarts (e.g., K8s), as each restart results in a new owner_id, forcing unnecessary partition rebalancing and checkpoint contention.

Describe the solution you'd like
Add an optional parameter (owner_id: Optional[str] = None) to the said methods. If provided, this value would override the auto-generated UUID. This allows users to pass a persistent identifier (e.g., pod FQDN) to:

  • Reduce partition ownership juggling during brief restarts.
  • Improve traceability with meaningful IDs.

Example usage:

client.receive_batch(
    on_event_batch=on_event_batch,
    on_error=on_error,
    owner_id=socket.getfqdn(),
)

Describe alternatives you've considered
As for now, I monkey patch EventProcessor.

Additional context
In my deployment, workers restart hourly (due to a custom proxy requiring credentials refresh) and use a custom MongoDB (is Web scale) checkpoint store with the following behavior:

  • Graceful shutdowns do not release partitions.
  • On restart, the same worker reclaims its previous partitions. But it only works if the owner_id is stable.

Explicit control over owner_id would greatly help in this solution.

Also, as I understand it, the Java SDK allows you to explicitly specify owner_id.

I’d be happy to implement this myself if the feature is approved.

Thank you in advance.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。