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) -> NoneEventMessage fields:
| Field | Type | Required | Description |
|---|---|---|---|
channel | str | Yes | Target channel |
body | bytes | Conditional* | Payload |
metadata | str | Conditional* | Text metadata |
tags | dict[str, str] | No | Key/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:
| Field | Type | Required | Description |
|---|---|---|---|
channel | str | Yes | Channel name |
group | str | No | Consumer group |
on_receive_event_callback | Callable | Yes | Delivery handler |
on_error_callback | Callable | Yes | Error handler |
Quick Usage
await client.publish_event(
EventMessage(channel="events.demo", body=b"hello")
)See Also
Was this page helpful?