KubeMQ
Client SDKsRustReference

Events

Event, EventReceive, and streaming types for fire-and-forget pub/sub

Event

Outbound fire-and-forget event message. Events are delivered to all active subscribers and then discarded.

FieldTypeDescription
idStringMessage ID (auto-generated UUID v4 when empty)
channelStringTarget channel name (required)
metadataStringOptional UTF-8 metadata
bodyVec<u8>Message payload bytes
client_idStringSender identity override
tagsHashMap<String, String>Arbitrary key-value pairs

Builder

main.rs
let event = Event::builder()
    .channel("notifications")
    .body(b"hello world".to_vec())
    .metadata("content-type:text/plain")
    .add_tag("source", "sensor-1")
    .build();

EventReceive

Received from a subscription callback.

FieldTypeDescription
idStringServer-assigned event identifier
channelStringChannel the event was published to
metadataStringPublisher metadata
bodyVec<u8>Message payload
timestampi64Server timestamp (Unix nanoseconds)
sequenceu64Monotonic sequence number within the channel
tagsHashMap<String, String>Publisher-attached tags

Client Methods

send_event

Sends a single fire-and-forget event.

main.rs
client.send_event(event).await?;

publish_event

Convenience method with minimal parameters.

main.rs
client.publish_event("notifications", b"alert".to_vec(), None, None).await?;

subscribe_to_events

Subscribes to events on a channel. Supports wildcards (*, >).

main.rs
let sub = client.subscribe_to_events(
    "events.>",
    "",
    |event| Box::pin(async move {
        println!("Received: {}", String::from_utf8_lossy(&event.body));
    }),
    None,
).await?;

sub.unsubscribe().await;

send_event_stream

Opens a bidirectional stream for high-throughput publishing. Returns an EventStreamHandle.

main.rs
let mut handle = client.send_event_stream().await?;
handle.send(event).await?;
handle.close();

EventStreamHandle

MethodDescription
send(event)Send an event through the stream
errors()Get a mutable reference to the error receiver
close()Close the stream

Was this page helpful?

On this page