Configuration Reference
Every PublisherConfig, SubscriberConfig, CQConfig, QueueMessagePolicy, and TLSConfig field, plus enums, validation rules, marshaling, and metadata keys.
This page is the authoritative configuration reference for the watermill-kubemq plugin:
every config field with its type and default, the enums and validation rules, the marshaling
contract, reserved metadata keys, and pinned dependency versions. The methods and constructors
themselves are in the API reference. Every entry is drawn from the plugin source;
where the repository README and the source disagree, the source wins and the discrepancy is
called out.
Package and import
The plugin module is published at github.com/kubemq-io/watermill-kubemq. All public types
live in the pkg/kubemq subpackage, conventionally imported under the alias kubemq:
import (
"github.com/ThreeDotsLabs/watermill"
"github.com/ThreeDotsLabs/watermill/message"
kubemq "github.com/kubemq-io/watermill-kubemq/pkg/kubemq"
)Install it with:
go get github.com/kubemq-io/watermill-kubemqThe plugin is a native gRPC client built on github.com/kubemq-io/kubemq-go/v2. It connects
to the KubeMQ broker's gRPC port (50000) directly — there is no HTTP connector and no
server-side enable flag to set, unlike the HTTP-based connectors. A broker reachable on
50000 is all that is required:
docker run -d \ --name kubemq \ -p 50000:50000 \ -p 8080:8080 \ -p 9090:9090 \ -e KUBEMQ_TOKEN=YOUR_LICENSE_KEY \ europe-docker.pkg.dev/kubemq/images/kubemq:nextPort 50000 is the gRPC API used by this plugin, 8080 exposes the REST API and health
endpoint, and 9090 exposes Prometheus metrics.
PublisherConfig
Configures NewPublisher. QueueMessagePolicy is only consulted when Pattern is
PatternQueues.
Prop
Type
SubscriberConfig
Configures NewSubscriber. The MaxItems and WaitTimeoutSeconds fields apply only to the
Queues pattern; the EventsStore* fields apply only to the EventsStore pattern.
Prop
Type
CQConfig
Configures NewCQPublisher.
Prop
Type
The repository README's CQConfig table omits three fields that exist in the source:
CacheKey, CacheTTL, and Marshaler. They are documented above from
pkg/kubemq/config.go. The README also marks DefaultTimeout as "(required)", but the
source applies a default of 5 * time.Second when it is <= 0, so it is effectively optional.
QueueMessagePolicy
Default delivery policy for queue messages, set on PublisherConfig.QueueMessagePolicy and
used only by the Queues pattern.
Prop
Type
These four fields are typed int (and string for MaxReceiveQueue) in
pkg/kubemq/config.go. The README reference table lists ExpirationSeconds, DelaySeconds,
and MaxReceiveCount as int32 — the source type is int.
TLSConfig
TLS settings for the connection, set on the TLS field of any config. File-based credentials
(CertFile) take precedence over PEM data (CertData).
Prop
Type
Enums
PatternType
Selects the KubeMQ messaging pattern for a Publisher or Subscriber. Each instance serves exactly one pattern.
| Constant | Value | String() |
|---|---|---|
PatternEvents | 0 | events |
PatternEventsStore | 1 | events_store |
PatternQueues | 2 | queues |
Any value outside this range fails validation, and String() returns unknown.
EventsStoreStartOption
Controls the starting position for an EventsStore subscription
(SubscriberConfig.EventsStoreStartOption).
| Constant | Value | Description |
|---|---|---|
StartFromNew | 0 | Only events published after subscribing (default). |
StartFromFirst | 1 | Replay all stored events from the beginning. |
StartFromLast | 2 | Replay the last event, then continue with new ones. |
StartFromSequence | 3 | Replay from a specific sequence number (EventsStoreSequence). |
StartFromTime | 4 | Replay from a specific point in time (EventsStoreStartTime). |
StartFromTimeDelta | 5 | Replay from now minus a duration (EventsStoreTimeDelta). |
Validation rules
Each config exposes a Validate() method, invoked automatically by its constructor.
Validation both rejects invalid input and applies defaults in place. The table below
summarizes the enforced rules.
| Config | Rule |
|---|---|
| All | Address is required when ExistingClient is nil (otherwise an error is returned). |
| Publisher / Subscriber | Pattern must be within PatternEvents..PatternQueues; out-of-range values error. |
| Publisher / Subscriber | A nil Marshaler/Unmarshaler defaults to DefaultMarshaler{}; a nil Logger defaults to watermill.NopLogger{}. |
| Subscriber (Queues) | MaxItems <= 0 defaults to 1; WaitTimeoutSeconds <= 0 defaults to 1. |
| Subscriber (EventsStore) | StartFromSequence requires EventsStoreSequence > 0; StartFromTime requires a non-zero EventsStoreStartTime; StartFromTimeDelta requires EventsStoreTimeDelta > 0. Each unmet condition returns an error. |
| CQ | DefaultTimeout <= 0 defaults to 5 * time.Second; a nil Marshaler defaults to DefaultMarshaler{}; a nil Logger defaults to watermill.NopLogger{}. |
Marshaling
The plugin converts between Watermill messages and KubeMQ messages through small intermediate types and three interfaces.
| Type | Kind | Purpose |
|---|---|---|
Marshaler | interface | Marshal(topic string, msg *message.Message) (*MarshaledMessage, error) — Watermill to KubeMQ. |
Unmarshaler | interface | Unmarshal(msg *ReceivedMessage) (*message.Message, error) — KubeMQ to Watermill. |
MarshalerUnmarshaler | interface | Embeds both Marshaler and Unmarshaler (used by CQConfig.Marshaler). |
DefaultMarshaler | struct | Default implementation of MarshalerUnmarshaler. |
MarshaledMessage | struct | { Body []byte; Tags map[string]string } — outbound intermediate. |
ReceivedMessage | struct | { ID string; Body []byte; Tags map[string]string } — inbound intermediate. |
DefaultMarshaler maps the Watermill payload to the KubeMQ message Body, and Watermill
metadata to KubeMQ Tags. The Watermill message UUID is stored under a reserved tag key
exported as the constant WatermillUUIDTag:
const WatermillUUIDTag = "_watermill_uuid"On marshal, the UUID is written to this tag, and supplying _watermill_uuid as a metadata key
yourself is rejected with an error (it is reserved). On unmarshal, the UUID is recovered from
the tag; if absent, the KubeMQ message ID is used; if that is also empty, a fresh
watermill.NewUUID() is generated. The _watermill_uuid tag is stripped from the
reconstructed Watermill metadata.
To customize wire format, implement Marshaler/Unmarshaler (or MarshalerUnmarshaler for
CQ) and set it on the corresponding config field — see the
Connection & Configuration guide for a worked compressed-marshaler example.
Reserved and auto-populated metadata keys
Several metadata keys carry special meaning. _watermill_uuid is reserved (you cannot set
it). The _kubemq_* keys are set by the subscriber on inbound messages from KubeMQ message
attributes. The W3C Trace Context keys are injected on publish and extracted on receive by the
OpenTelemetry propagator.
| Key | Direction | Set by | Notes |
|---|---|---|---|
_watermill_uuid | both | DefaultMarshaler | Stores the Watermill UUID. Reserved — supplying it as metadata errors. |
_kubemq_channel | inbound | Subscriber (Events, EventsStore) | KubeMQ channel the message arrived on. |
_kubemq_sequence | inbound | Subscriber (EventsStore) | EventsStore sequence number, as a string. |
_kubemq_timestamp | inbound | Subscriber (EventsStore) | EventsStore timestamp, RFC3339Nano. |
traceparent | both | OTel propagator | W3C Trace Context — injected on publish, extracted on receive. |
tracestate | both | OTel propagator | W3C Trace Context vendor state. |
Trace context propagation uses the globally configured OpenTelemetry TextMapPropagator. If no
propagator is registered in your process, the traceparent/tracestate keys are not added.
See the Middleware & Observability guide for the
OpenTelemetry setup.
Dependency versions
Pinned core dependencies, from go.mod:
| Dependency | Version |
|---|---|
| Go (toolchain) | 1.25.0 |
github.com/ThreeDotsLabs/watermill | v1.5.1 |
github.com/kubemq-io/kubemq-go/v2 | v2.0.3 |
go.opentelemetry.io/otel | v1.44.0 |
Related
Was this page helpful?