A telemetry ingestion system requires a .NET service to consume stream records from Azure Event Hubs. You plan to implement event processing using the Azure.Messaging.EventHubs.Processor namespace, using Azure Blob Storage for partition checkpoints. What is the correct sequence of API operations to manage the lifecycle of the client?
- 1Initialize the BlobContainerClient instance for checkpointing and the EventProcessorClient instance with the Event Hub and storage credentials.
- 2Register handler methods for the ProcessEventAsync and ProcessErrorAsync events of the EventProcessorClient.
- 3Call the StartProcessingAsync method on the EventProcessorClient to begin consuming events and managing partition leases.
- 4Call the StopProcessingAsync method on the EventProcessorClient when event consumption needs to be terminated.
Cevap
The correct sequence is to first initialize the BlobContainerClient and EventProcessorClient, then register callback methods for both ProcessEventAsync and ProcessErrorAsync, followed by calling StartProcessingAsync to start processing, and finally calling StopProcessingAsync to cleanly terminate consumption.
To consume events using the modern Azure.Messaging.EventHubs SDK, the developer must first initialize the required clients (BlobContainerClient and EventProcessorClient). Before processing can begin, the client requires that handler methods for both events and errors be registered. Once registered, StartProcessingAsync is called to begin operations. To shut down cleanly and release partition leases, StopProcessingAsync must be called.
Adım Adım Çözüm
Anahtar Kavram
Managing the lifecycle of EventProcessorClient in Azure Event Hubs .NET SDK