KubeMQ
IntegrationsFastStreamReference

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

FactValue
Package namekubemq-faststream
Version0.1.0 (Development Status: 4 - Beta)
LicenseMIT
Python3.11+ (tested on 3.11, 3.12, 3.13)
FastStream dependencyfaststream>=0.6.7,<0.7.0
KubeMQ SDK dependencykubemq>=4.1.5,<5

Install with uv or pip:

uv add kubemq-faststream
pip install kubemq-faststream

kubemq-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.

ParameterTypePurpose
decoderCustomCallable | NoneCustom message decoder applied broker-wide
parserCustomCallable | NoneCustom message parser applied broker-wide
dependenciesIterable[Dependant]FastDepends dependencies injected into every handler
middlewaresSequence[BrokerMiddleware]Broker-level middleware chain
routersIterable[KubeMQRegistrator]Routers to include at construction time
securityBaseSecurity | NoneAsyncAPI security scheme
specification_urlstr | Iterable[str] | NoneAsyncAPI server URL(s); defaults to the broker URL
protocolstr | NoneAsyncAPI protocol label; defaults to kubemq or kubemq+tls
protocol_versionstr | NoneAsyncAPI protocol version; defaults to "1.0"
descriptionstr | NoneAsyncAPI broker description
tagsIterable[Tag | TagDict]AsyncAPI tags
loggerLoggerProto | NoneCustom logger; FastStream default when unset
log_levelintLogging level (default logging.INFO)
apply_typesboolEnable FastDepends type casting (default True)
serializerSerializerProto | NoneCustom FastDepends serializer
providerProvider | NoneFastDepends dependency provider
contextContextRepo | NoneFastStream context repository
include_in_schemaboolInclude broker in the generated AsyncAPI schema (default True)
prefixstrChannel prefix prepended to every handler on this broker

URL Formats

The url argument (or the KUBEMQ_ADDRESS environment variable) accepts three forms:

FormatDescription
kubemq://host:portPlain gRPC connection
kubemq+tls://host:portgRPC with TLS (sets tls_enabled implicitly)
host:portPlain gRPC, bare form (no scheme)
KubeMQBroker("kubemq://localhost:50000")           # plain
KubeMQBroker("kubemq+tls://broker.example:50000")  # TLS via scheme
KubeMQBroker("localhost:50000")                    # bare host:port

Environment 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 VariableConstructor ParameterDefault
KUBEMQ_ADDRESSurlkubemq://localhost:50000
KUBEMQ_CLIENT_IDclient_idSystem hostname
KUBEMQ_AUTH_TOKENauth_tokenNone (no auth)
KUBEMQ_TLS_ENABLEDtls_enabledfalse
KUBEMQ_TLS_CERT_FILEtls_cert_fileNone
KUBEMQ_TLS_KEY_FILEtls_key_fileNone
KUBEMQ_TLS_CA_FILEtls_ca_fileNone
KUBEMQ_MAX_SEND_SIZEmax_send_size4194304
KUBEMQ_MAX_RECEIVE_SIZEmax_receive_size4194304
KUBEMQ_DEFAULT_CQ_TIMEOUTdefault_cq_timeout30

A broker constructed with no arguments reads its entire configuration from the environment:

env_var_config.py
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_ID

Validation 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_size must be greater than 0.
  • max_receive_size must be greater than 0.
  • default_cq_timeout must be greater than 0.
  • For mutual TLS, tls_cert_file and tls_key_file are paired: setting one without the other raises ValueError.
  • An auth_token that 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?

On this page