본문으로 건너뛰기
Skillpedia
API 및 서버 (백엔드)48k · #3930

azure-eventhub-rust

하는 일

Rust 프로그램이 Azure Event Hubs라는 서비스와 데이터(이벤트)를 주고받도록 해 주는 코드입니다. 대량의 실시간 데이터를 모으는 데 유용합니다.

사용하는 경우

  • ✓분석을 위해 많은 센서 데이터를 보낼 때.
  • ✓다른 시스템의 메시지를 받아 처리할 때.
  • ✓실시간 활동을 기록하는 시스템을 만들 때.

스킬 링크

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/azure-eventhub-rust/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/azure-eventhub-rust/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“Rust를 사용해 Azure Event Hubs에 간단한 메시지를 보내려면 어떻게 하나요?”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

이벤트를 보내는 ‘프로듀서’나 받는 ‘컨슈머’를 만듭니다. 이 코드는 Azure 서비스에 연결하고 데이터를 보내거나 받는 작업을 관리합니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

Azure Event Hubs SDK for Rust

Client library for Azure Event Hubs — big data streaming platform and event ingestion service.

The examples below require a reviewed compatible crate set and replacement of every resource placeholder. Do not use production data for demonstration writes.

Installation

cargo add azure_messaging_eventhubs@=0.16.0 azure_identity@=1.1.0-beta.1 azure_core@=1.2.0-beta.1

Environment Variables

export EVENTHUBS_HOST="<namespace>.servicebus.windows.net"
export EVENTHUB_NAME="<eventhub-name>"

Key Concepts

  • Namespace — container for Event Hubs
  • Event Hub — stream of events partitioned for parallel processing
  • Partition — ordered sequence of events
  • Producer — sends events to Event Hub
  • Consumer — receives events from partitions

Producer Client

Create Producer

use azure_identity::DeveloperToolsCredential;
use azure_messaging_eventhubs::ProducerClient;

let credential = DeveloperToolsCredential::new(None)?;
let producer = ProducerClient::builder()
    .open("<namespace>.servicebus.windows.net", "eventhub-name", credential.clone())
    .await?;

Send Single Event

producer.send_event(vec![1, 2, 3, 4], None).await?;

Send Batch

let batch = producer.create_batch(None).await?;
if !batch.try_add_event_data(b"event 1".to_vec(), None)? {
    return Err("Event does not fit in the batch".into());
}
if !batch.try_add_event_data(b"event 2".to_vec(), None)? {
    return Err("Send the existing batch and retry the remaining event in a new batch".into());
}

producer.send_batch(batch, None).await?;

Consumer Client

Create Consumer

use azure_messaging_eventhubs::ConsumerClient;

let credential = DeveloperToolsCredential::new(None)?;
let consumer = ConsumerClient::builder()
    .open("<namespace>.servicebus.windows.net", "eventhub-name", credential.clone())
    .await?;

Receive Events

// Open receiver for specific partition
use futures::StreamExt;
let receiver = consumer.open_receiver_on_partition("0".to_string(), None).await?;
let mut events = receiver.stream_events();
// Bound the receive loop and handle the no-event timeout without logging payloads.
for _ in 0..100 {
    match tokio::time::timeout(std::time::Duration::from_secs(10), events.next()).await {
        Ok(Some(Ok(event))) => { /* process the authorized event and checkpoint safely */ }
        Ok(Some(Err(error))) => return Err(error.into()),
        Ok(None) | Err(_) => break,
    }
}

Get Event Hub Properties

let properties = consumer.get_eventhub_properties(None).await?;
println!("Partitions: {:?}", properties.partition_ids);

Get Partition Properties

let partition_props = consumer.get_partition_properties("0", None).await?;
println!("Last sequence number: {}", partition_props.last_enqueued_sequence_number);

Best Practices

  1. Reuse clients — create once, send many events
  2. Use batches — more efficient than individual sends
  3. Check batch capacity — try_add_event_data returns false when full
  4. Process partitions in parallel — each partition can be consumed independently
  5. Use consumer groups — isolate different consuming applications
  6. Handle checkpointing — use azure_messaging_eventhubs_checkpointstore_blob for distributed consumers

Checkpoint Store (Optional)

For distributed consumers with checkpointing:

cargo add azure_messaging_eventhubs_checkpointstore_blob

Event Hubs 0.16 uses the Azure core beta line, so pair it with the published matching identity beta; do not mix credential traits from the stable core line.

The reviewed example set uses azure_messaging_eventhubs 0.16.0 and compatible Azure core/credential crates. Record and commit Cargo.lock; source/API review is not a compiler or live-service test.

Reference Links

Resource Link
API Reference https://docs.rs/azure_messaging_eventhubs
Source Code https://github.com/Azure/azure-sdk-for-rust/tree/main/sdk/eventhubs/azure_messaging_eventhubs
crates.io https://crates.io/crates/azure_messaging_eventhubs

When to Use

Use when a Rust application publishes individual/batched events or consumes a specific Event Hubs partition with an explicit consumer group and checkpoint policy.

Limitations

…

자주 묻는 질문

‘Namespace’ 또는 ‘Event Hub’는 무엇인가요?

Namespace는 Event Hub를 담는 컨테이너와 같습니다. Event Hub는 이벤트가 파티션으로 나뉘어 정리되는 데이터 스트림입니다.

‘프로듀서’와 ‘컨슈머’는 무엇인가요?

프로듀서는 Event Hub에 이벤트를 보내는 쪽이고, 컨슈머는 특정 파티션에서 이벤트를 읽는 쪽입니다.

여러 이벤트를 한 번에 보낼 수 있나요?

네, 여러 이벤트를 ‘배치’로 묶어 더 효율적으로 보낼 수 있습니다.

상세 정보

작성자의 원본 설명

Azure Event Hubs SDK for Rust. Use for sending and receiving events, streaming data ingestion.

repo: sickn33/agentic-awesome-skills

인기도

GitHub 스타
48k
순위
#3930
라이선스
MIT
업데이트
2026. 10. 15.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬