Configuration Reference
The kubemq-faststream connection surface — package facts, KubeMQBroker constructor options, URL formats, validation rules, and environment variables.
This page is the configuration reference for kubemq-faststream: package facts, the
KubeMQBroker constructor surface, URL formats, validation rules, the
environment-variable overrides, and the FastStream standard broker options. For the
exported symbols, enums, subscriber fields, and the broker.request() signature, see the
API reference. For runnable walkthroughs,
start with Getting Started.
Package Facts
| Fact | Value |
|---|---|
| Package name | kubemq-faststream |
| Version | 0.1.0 (Development Status: 4 - Beta) |
| License | MIT |
| Python | 3.11+ (tested on 3.11, 3.12, 3.13) |
| FastStream dependency | faststream>=0.6.7,<0.7.0 |
| KubeMQ SDK dependency | kubemq>=4.1.5,<5 |
Install with uv or pip:
uv add kubemq-faststreampip install kubemq-faststreamkubemq-faststream is a native gRPC SDK client that talks to KubeMQ over the gRPC port
50000. It is always on — there is no server-side connector enable flag to set. Start
a broker with docker run -d --rm -p 50000:50000 -p 9090:9090 -e KUBEMQ_TOKEN=YOUR_LICENSE_KEY europe-docker.pkg.dev/kubemq/images/kubemq:next.
Port 50000 is the gRPC transport the adapter uses; port 9090 is the shared HTTP server
and is not required for FastStream.
KubeMQBroker Constructor
KubeMQBroker extends FastStream's BrokerUsecase, so it accepts the standard FastStream
broker options alongside the KubeMQ-specific connection settings. The first positional
argument is the broker URL; everything else is keyword-only.
from kubemq_faststream import KubeMQBroker
broker = KubeMQBroker(
"kubemq://localhost:50000",
client_id="my-service",
auth_token="my-token",
default_cq_timeout=30,
graceful_timeout=15.0,
)KubeMQ Connection Parameters
Prop
Type
mTLS requires both tls_cert_file and tls_key_file. Supplying one without the other raises ValueError at construction time. Likewise, max_send_size, max_receive_size, and default_cq_timeout must all be greater than zero.
For TLS, mTLS, and authentication setups with full examples, see Configuration & Security.
FastStream Standard Parameters
These keyword-only options mirror the other FastStream brokers (the KafkaBroker
pattern). They are optional and default to FastStream's standard values.
| Parameter | Type | Purpose |
|---|---|---|
decoder | CustomCallable | None | Custom message decoder applied broker-wide |
parser | CustomCallable | None | Custom message parser applied broker-wide |
dependencies | Iterable[Dependant] | FastDepends dependencies injected into every handler |
middlewares | Sequence[BrokerMiddleware] | Broker-level middleware chain |
routers | Iterable[KubeMQRegistrator] | Routers to include at construction time |
security | BaseSecurity | None | AsyncAPI security scheme |
specification_url | str | Iterable[str] | None | AsyncAPI server URL(s); defaults to the broker URL |
protocol | str | None | AsyncAPI protocol label; defaults to kubemq or kubemq+tls |
protocol_version | str | None | AsyncAPI protocol version; defaults to "1.0" |
description | str | None | AsyncAPI broker description |
tags | Iterable[Tag | TagDict] | AsyncAPI tags |
logger | LoggerProto | None | Custom logger; FastStream default when unset |
log_level | int | Logging level (default logging.INFO) |
apply_types | bool | Enable FastDepends type casting (default True) |
serializer | SerializerProto | None | Custom FastDepends serializer |
provider | Provider | None | FastDepends dependency provider |
context | ContextRepo | None | FastStream context repository |
include_in_schema | bool | Include broker in the generated AsyncAPI schema (default True) |
prefix | str | Channel prefix prepended to every handler on this broker |
URL Formats
The url argument (or the KUBEMQ_ADDRESS environment variable) accepts three forms:
| Format | Description |
|---|---|
kubemq://host:port | Plain gRPC connection |
kubemq+tls://host:port | gRPC with TLS (sets tls_enabled implicitly) |
host:port | Plain gRPC, bare form (no scheme) |
KubeMQBroker("kubemq://localhost:50000") # plain
KubeMQBroker("kubemq+tls://broker.example:50000") # TLS via scheme
KubeMQBroker("localhost:50000") # bare host:portEnvironment Variables
Every connection parameter can be supplied through an environment variable. Environment variables take precedence over constructor arguments when set, so you can ship code with sensible defaults and override the target broker at deploy time without changing source.
| Environment Variable | Constructor Parameter | Default |
|---|---|---|
KUBEMQ_ADDRESS | url | kubemq://localhost:50000 |
KUBEMQ_CLIENT_ID | client_id | System hostname |
KUBEMQ_AUTH_TOKEN | auth_token | None (no auth) |
KUBEMQ_TLS_ENABLED | tls_enabled | false |
KUBEMQ_TLS_CERT_FILE | tls_cert_file | None |
KUBEMQ_TLS_KEY_FILE | tls_key_file | None |
KUBEMQ_TLS_CA_FILE | tls_ca_file | None |
KUBEMQ_MAX_SEND_SIZE | max_send_size | 4194304 |
KUBEMQ_MAX_RECEIVE_SIZE | max_receive_size | 4194304 |
KUBEMQ_DEFAULT_CQ_TIMEOUT | default_cq_timeout | 30 |
A broker constructed with no arguments reads its entire configuration from the environment:
import os
from kubemq_faststream import KubeMQBroker
os.environ.setdefault("KUBEMQ_ADDRESS", "localhost:50000")
os.environ.setdefault("KUBEMQ_CLIENT_ID", "env-var-demo")
broker = KubeMQBroker() # picks up KUBEMQ_ADDRESS and KUBEMQ_CLIENT_IDValidation Rules
The broker config validates these settings as it is constructed. Violations raise
ValueError immediately — before any connection is attempted — so misconfiguration fails
fast:
max_send_sizemust be greater than0.max_receive_sizemust be greater than0.default_cq_timeoutmust be greater than0.- For mutual TLS,
tls_cert_fileandtls_key_fileare paired: setting one without the other raisesValueError. - An
auth_tokenthat is set but blank (empty or whitespace-only) is rejected. To run without authentication, leave the token unset rather than passing an empty string.
See also
Was this page helpful?
API Reference
The kubemq-faststream public API — exported symbols, the pattern and ack enums, StartPosition, subscriber config, and the broker.request() RPC signature.
Resilient Messaging Pipelines
Build production-grade workflows — saga, DLQ, circuit breaker, idempotency, and event sourcing — on KubeMQ FastStream.