Four kinds of people deal with the broker client. Most of them never open this repository; this page tells each one what they touch and where the detail is.
Four kinds of people deal with the broker client. Most of them never open this repository; this page tells each one what they touch and where the detail is.
You write routes; the extension creates the broker clients for them. You configure, you do not construct.
klok.broker.* keys (klok.broker.service.url, klok.broker.auth.url,
klok.broker.auth.client-id, klok.broker.auth.client-secret, klok.broker.tls-trust-certs-file-path,
klok.broker.listener-threads), which MicroProfile fills from the KLOK_BROKER_* variables of the service's Vault env
secret. Nothing per route. See Configuration.<RouteId>.subscription.concurrency for several receive loops (and with it a Shared subscription
unless <RouteId>.subscription.type says otherwise), <RouteId>.subscription.type,
<RouteId>.subscription.nack-redelivery-delay-ms, <RouteId>.subscription.receiver-queue-size, and
<RouteId>.subscription.batch.max-messages / .max-wait-ms for a batch route. Any concurrency above one gives up the
order. See Concurrency and Batches.klok.broker.verify-topics,
on by default). A missing one stops the start with TOPIC_MISSING or TOPIC_ACCESS_DENIED and a message that names the
topic, the klok.dev request link and the line to add by hand. Do what it says; see Missing topics and
grants.KlokOdl, runs on KlokBrokerClientSync. The reply is addressed to
your instance and arrives there alone; a timeout or broker failure is a KlokRequestReplyException, which KlokOdl
reports as UPSTREAM_UNAVAILABLE. See Request/reply.KLOK_BROKER_CONNECTION means a producer or consumer of your service lost the broker, or a
subscription stopped reading; see Connection health. The extension's readiness and liveness
checks report the same state (Health
checks).You write a plain Java service, a Node process or a Python worker that takes part in Klok chains.
publish or consume grants on its topics; its
credentials reach it as KLOK_BROKER_AUTH_CLIENT_ID and KLOK_BROKER_AUTH_CLIENT_SECRET from its Vault env object. Who
creates them is in the framework development guide, Service
Identities.klokLibs.klokBrokerclientJava from the dependency catalog and add an SLF4J provider. Build the
configuration with KlokBrokerClientConfig.buildFromEnv(), name every topic in full with
KlokNamingConventions.fullTopicName, check your topics at start with verifyPublish and verifyConsume, subscribe
with KlokSubscriptionOptions.builder("<your route id>"), and close every client when the service stops. A handler that
returns acknowledges, one that throws negatively acknowledges, and subscribeWithOutcome lets it decide. Unlike the
extension, the plain client does not retry or dead letter a failed message for you, and it sets only klok-instance,
klok-sent-time and klok-body-type: pass the chain context (klok-corr-global, klok-corr-platform and the rest) in
the properties of what you publish, and the client keys the message by the global id and writes it as
klok-correlation-id too for services built before the three ids. Serve requests with
KlokBrokerClientSync.handleRequests. Report connectionHealth() and subscriptionHealth() from your health endpoint.
The pages: Configuration, Authentication and subscriptions, Properties
and CloudEvents, Connection health. A service with its own payload
encoding uses KlokBytesBrokerClient (Bytes client).npm install @klok-integration/brokerclient, then new KlokBrokerClient() from the environment,
publish, subscribe and runUntilSignal(). The client derives the chain context, retries, dead letters and logs
every invocation like a Java route. See TypeScript client.pip install klok-brokerclient from the GitLab PyPI registry, then the same shape as TypeScript. See
Python client and workers.KlokClaimCheckStore (Java and TypeScript),
and the message carries its klokcc:// reference; the service gets a RustFS key of its own as KLOK_BLOBSTORE_*. See
Claim check.You get an alert, or see a service that has stopped working although its pod is Running.
klok-logs-<namespace>-console-* in OpenSearch) for KLOK_BROKER_CONNECTION. Every
state but RESTORED means broken; the fields name the topic, the kind of handle, the route and the instance.
RECEIVE_LOOP_STOPPED is a subscription that no longer reads with all its loops, and FATAL_ERROR a JVM that ran out
of memory: only a restart ends either.Failed to authenticate the client line, which points at the
service's Keycloak client or its secret../gradlew build (Java 21, a GitLab token for the group registry) and
is tested against a broker with ./gradlew integrationTest; the TypeScript client with npm test and npm run test:integration, the Python client with pytest. How to start the brokers they need is on Testing.majorVersion, minorVersion, patchVersion in gradle.properties; the pipeline appends
the timestamp. TypeScript and Python: <major.minor> in package.json and pyproject.toml; the pipeline sets the last
part to its pipeline number.klok catalog release-dependents starts this repository's
main pipeline, whose build_job refreshes gradle/klok-libs.versions.toml and builds against it. klok-common and
pulsar-client come from that catalog; the other dependencies are still pinned in gradle/libs.versions.toml
(#18). The wire contract copies in
typescript/klok-brokerclient-typescript/wire-contract/ and
python/klok-brokerclient-python/src/klok_brokerclient/wire_contract/ follow too: the job wire_contract_sync runs
klok vendor sync --latest before the Python and TypeScript tests and packages, so a contract that breaks a client
fails its tests, and the job klok vendor check fails when a committed copy differs from its release. To work against
the new contract locally, or to move the committed copy, run klok vendor sync --latest and commit it. Never edit a
copy by hand (Vendored copies).java-integration-test, java-integration-test-auth) only when Java files changed (src/, build.gradle,
settings.gradle, gradle/), the Python tests when python/ changed, and the TypeScript tests when typescript/ or
python/ changed. A merge request typed docs that touches only klok-docs/ and the README runs only the
documentation lane.main:release_and_publish_job releases to the GitLab registry and maven_central_release sends the same files to
Maven Central, which may fail or wait for Central without holding anything back. Both run only when Java changed, like
the build. Then update_klok_catalog writes klokBrokerclient into the dependency catalog and runs klok catalog release-dependents, which starts the Quarkus extension's pipeline when the extension was built against an older broker
client. Wait for the catalog commit, not for the merge:glab api --hostname git.klok.dev "projects/klok%2Fframework%2Fklok-gradle-dependency-catalog/repository/commits?ref_name=main&per_page=10" | jq -r '.[].title'
python/ changed: the package is built and uploaded to the project's GitLab PyPI registry.typescript/ changed: the tarball is staged on npmjs.org, and a maintainer approves it with 2FA under
Staged Packages on npmjs.com or with npm stage approve <id> (Releases).