KubeMQ
Client SDKsPythonReference

Events

Fire-and-forget pub/sub — KubeMQ Python SDK reference.

Publish events with publish_event and consume them through subscribe_to_events, supplying EventsSubscription plus an AsyncCancellationToken for shutdown.

publish_event

await client.publish_event(message: EventMessage) -> None

EventMessage fields:

FieldTypeRequiredDescription
channelstrYesTarget channel
bodybytesConditional*Payload
metadatastrConditional*Text metadata
tagsdict[str, str]NoKey/value tags

*At least one of body or metadata must be set.

Returns: None — raises on failure.

Throws: KubeMQError — validation or transport errors.

subscribe_to_events

subscribe_to_events is an async generator — iterate it with async for:

async for event in client.subscribe_to_events(
    subscription=EventsSubscription(...),
    cancellation_token=token,
):
    process(event)

EventsSubscription fields:

FieldTypeRequiredDescription
channelstrYesChannel name
groupstrNoConsumer group
on_receive_event_callbackCallableYesDelivery handler
on_error_callbackCallableYesError handler

Quick Usage

events.py
await client.publish_event(
    EventMessage(channel="events.demo", body=b"hello")
)

See Also

Was this page helpful?

On this page