Langsung ke konten
Skillpedia
API & server (backend)48k Β· #3930

azure-eventhub-rust

Fungsinya

Kode ini memungkinkan program Rust mengirim dan menerima data (event) dari layanan bernama Azure Event Hubs. Kode ini berguna untuk mengumpulkan data real-time dalam jumlah besar.

Kapan dipakai

  • βœ“Mengirim banyak data sensor untuk dianalisis.
  • βœ“Menerima pesan dari sistem lain untuk diproses.
  • βœ“Membangun sistem yang mencatat aktivitas secara real-time.

Link skill

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

Salin lalu tempelkan ke AI Anda (Claude, ChatGPT, atau Cursor) dan minta AI mengikuti instruksinya.

Cara pakai

Cara paling mudah: salin pesan ini dan tempelkan ke AI Anda. AI akan membaca skill dan mengikuti instruksinya.

Pesan siap tempel

Gunakan skill ini untuk membantu saya: https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/azure-eventhub-rust/SKILL.md Baca file SKILL.md di link tersebut dan ikuti instruksinya untuk tugas saya.
Mau AI Anda menemukan skill seperti ini sendiri?Pasang MCP Skillpedia gratis: cukup satu baris, dan AI mencari di antara 15.000+ skill sebelum tiap tugas.Pasang dalam 1 menit β†’

Contoh permintaan ke AI

β€œBagaimana cara mengirim pesan sederhana ke Azure Event Hubs menggunakan Rust?”

5 skill baru setiap minggu. 1 menit baca.

Cara kerjanya

Anda membuat 'producer' untuk mengirim event atau 'consumer' untuk menerimanya. Kode ini terhubung ke layanan Azure dan mengatur proses pengiriman atau penerimaan data.

Konten teknis (SKILL.md asli)

Teks asli dari pembuat, dalam bahasa Inggris, langsung dari 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

…

Pertanyaan umum

Apa itu 'Namespace' atau 'Event Hub'?

Namespace adalah wadah untuk Event Hub Anda. Event Hub adalah aliran data tempat event diatur ke dalam partisi.

Apa itu 'Producer' dan 'Consumer'?

Producer adalah pihak yang mengirim event ke Event Hub. Consumer adalah pihak yang membaca event dari partisi tertentu.

Bisakah saya mengirim beberapa event sekaligus?

Bisa. Anda dapat mengelompokkan beberapa event ke dalam 'batch' agar pengiriman lebih efisien.

Detail

Deskripsi asli dari pembuat

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

repo: sickn33/agentic-awesome-skills

Popularitas

Bintang GitHub
48k
Peringkat
#3930
Lisensi
MIT
Diperbarui
15/10/2026

Apakah skill ini berguna?

0

Masuk untuk memberi suara.

Komentar

  • …

Skill lain dari repositori ini

Skill serupa