
以下为本文档的中文说明azure-eventhub-rust 是 Azure Event Hubs 在 Rust 语言上的客户端 SDK 技能。Azure Event Hubs 是一个大数据流式处理平台和事件引入服务能够每秒处理数百万条事件适用于实时数据分析、物联网设备数据采集、日志流处理等场景。该技能的核心概念包括命名空间Namespace——Event Hubs 的容器事件中心Event Hub——分区后用于并行处理的事件流分区Partition——有序的事件序列生产者Producer——向事件中心发送事件的客户端消费者Consumer——从分区接收事件的客户端。使用场景包括在 Rust 应用中发送和接收事件、实现流式数据引入、构建实时数据处理管道。安装方式简单只需在 Cargo.toml 中添加 azure_messaging_eventhubs 和 azure_identity 两个依赖包。配置方面需要设置 EVENTHUBS_HOST 和 EVENTHUB_NAME 两个环境变量。该技能提供了 ProducerClient 和 ConsumerClient 的完整 API 示例代码包括使用 DeveloperToolsCredential 进行身份验证、创建生产者客户端、发送事件到事件中心、以及从分区消费事件等操作。它适合需要在 Rust 生态系统中使用 Azure 云服务的开发者特别是从事物联网、日志处理和实时分析项目的团队。Azure Event Hubs SDK for RustClient library for Azure Event Hubs — big data streaming platform and event ingestion service.Installationcargoaddazure_messaging_eventhubs azure_identityEnvironment VariablesEVENTHUBS_HOSTnamespace.servicebus.windows.netEVENTHUB_NAMEeventhub-nameKey ConceptsNamespace— container for Event HubsEvent Hub— stream of events partitioned for parallel processingPartition— ordered sequence of eventsProducer— sends events to Event HubConsumer— receives events from partitionsProducer ClientCreate Produceruseazure_identity::DeveloperToolsCredential;useazure_messaging_eventhubs::ProducerClient;letcredentialDeveloperToolsCredential::new(None)?;letproducerProducerClient::builder().open(namespace.servicebus.windows.net,eventhub-name,credential.clone()).await?;Send Single Eventproducer.send_event(vec![1,2,3,4],None).await?;Send Batchletbatchproducer.create_batch(None).await?;batch.try_add_event_data(bevent 1.to_vec(),None)?;batch.try_add_event_data(bevent 2.to_vec(),None)?;producer.send_batch(batch,None).await?;Consumer ClientCreate Consumeruseazure_messaging_eventhubs::ConsumerClient;letcredentialDeveloperToolsCredential::new(None)?;letconsumerConsumerClient::builder().open(namespace.servicebus.windows.net,eventhub-name,credential.clone()).await?;Receive Events// Open receiver for specific partitionletreceiverconsumer.open_partition_receiver(0,None).await?;// Receive eventsleteventsreceiver.receive_events(100,None).await?;foreventinevents{println!(Event data: {:?},event.body());}Get Event Hub Propertiesletpropertiesconsumer.get_eventhub_properties(None).await?;println!(Partitions: {:?},properties.partition_ids);Get Partition Propertiesletpartition_propsconsumer.get_partition_properties(0,None).await?;println!(Last sequence number: {},partition_props.last_enqueued_sequence_number);Best PracticesReuse clients— create once, send many eventsUse batches— more efficient than individual sendsCheck batch capacity—try_add_event_datareturns false when fullProcess partitions in parallel— each partition can be consumed independentlyUse consumer groups— isolate different consuming applicationsHandle checkpointing— useazure_messaging_eventhubs_checkpointstore_blobfor distributed consumersCheckpoint Store (Optional)For distributed consumers with checkpointing:cargoaddazure_messaging_eventhubs_checkpointstore_blobReference LinksResourceLinkAPI Referencehttps://docs.rs/azure_messaging_eventhubsSource Codehttps://github.com/Azure/azure-sdk-for-rust/tree/main/sdk/eventhubs/azure_messaging_eventhubscrates.iohttps://crates.io/crates/azure_messaging_eventhubsWhen to UseThis skill is applicable to execute the workflow or actions described in the overview.LimitationsUse this skill only when the task clearly matches the scope described above.Do not treat the output as a substitute for environment-specific validation, testing, or expert review.Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.