18 Broker

Broker

Every integration ends in topics and access. Each leg reads or writes topics on the broker, and a service may use only the topics its tenant's Pulsar file in Git declares, with the grants the file gives it. Broker shows that broker as it runs right now: every topic of a namespace, what flows and what waits, who reads and who publishes, and who may. It is also where a missing topic or grant is asked for and approved, so that nobody changes the broker by hand and nobody finds a missing topic only when a service fails to start. Most requests come from klok.dev itself, after each build on main; a person asks for the rest, and the topic's owner decides.

  • In the menu: Run → Broker (/monitoring/broker), with the tabs Topics, Requests (/monitoring/broker/requests) and Health (/monitoring/runtime-health)
  • For: developers and operators read and ask; a Tenant Admin, the Domain Admin of a namespace or a Klok Framework Admin approves, and the owners of the namespace's domain are told
  • Reads: the broker's admin API, live (nothing is stored); the tenant's Pulsar file on main of klok/environment/klok-environment-setup, through GitLab; the routes each build on main reports; the requests in klok.dev's database

What You See

Tab What it shows
Topics One namespace at a time, chosen in the row above the list; the dot beside it says whether the namespace is In Git, applied. The strip sums its topics, subscriptions, backlog and dead letters. One row per topic, read again every ten seconds: Source, Backlog, In / Out, Oldest and DLQ. Only problems keeps the topics with a backlog nobody reads, dead letters, or no topic on the broker; Columns adds publishers, subscriptions, concurrency and the time left
Requests The requests for topics and access, from people and from klok.dev after a build: To approve (what waits for you), Ours (what your tenant asked for, klok.dev's requests for your projects among them) and All, with Approve and apply and Reject… on the rows you may decide
Health The totals over every namespace you may see, and the two lists that need someone: Backlog with no consumer and Dead-letter queues with messages

Source says where a topic is known: Broker (it exists), Git (the tenant's Pulsar file lists it) and Routes (a build on main reports a route that publishes or reads it). A topic only routes know of is marked Not on the broker; one in Git that the broker lacks is Not applied yet.

A topic's name says what it is:

Part of persistent://klok/hr/PersonnelScheduleExportV1 What it is
klok The tenant. The name decides the tenant, never the message
hr The domain: a namespace of its own on the broker
PersonnelScheduleExportV1 The datamodel, the contract between the legs
_<purpose> (none here; _heroma on PersonnelEmploymentBatchV1_heroma) Optional: the flow, when one datamodel carries several

A reader is not in the name. It is a subscription, named after the route that reads: KLK010E2_PersonecScheduleFileOfframp reads the export.

Walkthrough: Find Out What Is Waiting

  1. Open Run → Broker and choose the namespace, here klok/hr. The busiest topics are first when you sort by In / Out; hover the rates for the acknowledgement rate, the real speed of the readers.

  2. Read the row. A growing Backlog with a steady acknowledgement rate is a reader slower than its publisher; a backlog that stands still with no acknowledgements is a stopped reader. A red dot under DLQ means dead letters wait: here three schedule exports that KLK010E2_PersonecScheduleFileOfframp could not deliver over SFTP last night. The dot opens the dead-letter topic, PersonnelScheduleExportV1_DLQ, with the age of its oldest message.

  3. Open the topic by its name. Subscriptions has one row per reading route, with its backlog, rates, unacknowledged messages, concurrency and the pods it runs on; Publishers the producers connected now; Routes the routes the builds declare, with their solution; Grants who may publish and consume, in Git and on the broker.

  4. Open Health to see the same across every namespace you may see. Backlog with no consumer lists messages that nobody reads, here a subscription left from the retired KLK011; Dead-letter queues with messages lists every _DLQ that holds something.

Broker shows dead letters and leaves them where they are. A dead letter is kept, not lost, until someone has found and fixed its cause: Retries, DLQ, And Failure Events has the checklist.

Walkthrough: Ask For A Topic, And Approve It

The broker never creates a topic by itself, so a new topic, and a grant to read or publish, is asked for, and the topic's owner approves it. Requests come from two places.

klok.dev asks after each build on main. When a build publishes the project's documentation, klok.dev checks the topics its routes need, the same list ./gradlew klokTopics prints, against the owners' Pulsar files and the broker, and opens the request a developer would have made for each one that is missing, with the project's service as the reader and the routes that need it in the note. What it asks for follows the grant rules:

The routes need klok.dev asks for
A topic in the project's own namespaces, its domain's and its tenant's common The namespace grant, publish and consume, for the service, and the topic itself when it is missing
A topic of another domain or tenant they read consume on that one topic, in its owner's file, which declares the topic too when it is missing
The generic topic of a datamodel, <Model> without a purpose Nothing to approve: klok.dev declares it at once, as Ensure does
publish outside the project's own namespaces Nothing: write narrow, consume wide does not give it, and the project's Broker setup says why

Each change is asked for once, and one an owner rejected is not asked again. The project's Broker setup shows, topic by topic, the request behind each problem and what it waits for.

A person asks for the rest, such as a purpose topic, or access before the project's first build:

  1. Open Request topic or access: from the header of Broker, New request on Requests, Request it on a project's Broker setup, Request a purpose topic on a datamodel's Topics, or the link in a TOPIC_MISSING or TOPIC_ACCESS_DENIED message.

  2. What you need is one of Create the topic, Consume (read) the topic or Publish in its namespace. Then the topic's full name, for consume or publish the Keycloak client id of the service, and why. The line under the name says who owns the topic and who approves it, and its ⓘ names the file to change by hand. A request that breaks write narrow, consume wide, such as publishing in another tenant's namespace, is refused here.

  3. Send request stores the request in klok.dev.

The owner decides. A new request, a person's or klok.dev's, reaches the owners of the namespace's domain (the tenant's owners for common and public) as a message in their owners mailbox in Secure Mail, or the admins' mailbox while there is no owner; only when no mailbox has anyone does it go by e-mail to the people who may approve it.

  1. A Tenant Admin of the owning tenant, a Domain Admin of the namespace (not common or public) or a Klok Framework Admin opens Requests and reads the row under To approve. A request klok.dev made shows klok.dev as the requester, with For the build of <project> under it, and the search finds it by the project too.
  2. Approve and apply, or Reject… with a reason. A person who asked gets the reason by e-mail; for klok.dev's request it is shown on the project's Broker setup, so write it for the developer.
  3. On approval klok.dev writes the change into the owner's Pulsar file in a merge request, merges it and applies the file: the request becomes Applied, with a link to its merge request, and the topic exists with its _DLQ. If GitLab refuses the merge, the request stays Approved, not applied yet and says why; Apply again tries once more.

What Happens In Git

In klok.dev What it writes Who decides By hand
Topics, a topic's page, Health Nothing: klok.dev reads the broker with code that can only send GET — —
A build on main (nothing to click) Nothing in Git yet: a request in klok.dev's database with klok.dev as the requester and the project named; a datamodel's missing generic topic is a merge request that klok.dev merges and applies at once The owner approves; the generic topic needs nobody Request topic or access, or the lines in the owner's Pulsar file
Send request Nothing in Git yet: a request in klok.dev's database, and a message to the owners — —
Approve and apply A merge request to the owner's Pulsar file, which klok.dev merges; then it creates the topic, with its companions, or the grant on the broker The owner approves; klok.dev merges and applies The same line in a merge request of your own, applied by Ensure or Ansible after the merge
Reject… Nothing in Git; the requester gets the reason The owner Leave the merge request unmerged
Apply again The same merge and apply, once more — Ensure

The merge request is a commit on a klok-dev/… branch of klok/environment/klok-environment-setup that changes ansible-master/playbooks/group_vars/all/pulsar_tenant_<tenant>.yml, titled for example feat(pulsar): create persistent://klok/hr/PersonnelAbsencePeriodV1_heroma or feat(pulsar): grant <reader> consume on <topic>. klok.dev applies it with a provisioning identity of its own that may only create topics and grant. By hand, ansible-playbook playbooks/pulsar-check.yml checks the file before the merge; after it, the next Ensure applies it, or a person runs ansible-playbook playbooks/pulsar.yml --check --diff and then the same without --check.

Git stays the truth. A topic or grant made only through the broker's admin API is drift: such a grant shows as On the broker, not in Git (drift) under a topic's Grants, such a topic as Broker without Git under Source, and Ensure reports both without removing them. See What klok.dev Does In Git for every page.

Who Does What

Automation Kloker You
After each build on main, klok.dev asks the owners for the topics and grants the project's routes need, as the grant rules give them, once per change, declares a datamodel's generic topic itself, and e-mails the project's people when a new problem appears, saying where each one stands. It reads the broker live, every ten seconds on Topics, and stores nothing; after an approval it writes the merge request, merges it and applies the file; Ensure, which a platform admin starts, applies what was merged by hand and reports drift. The framework checks every topic a service uses at startup, with the request link in its log; from klok-quarkus-extension 3.14.0 it holds the routes that need a missing or ungranted one and runs the rest of the service, an older version does not start at all; the CI job klok_topic_check warns before the deploy and stops it on main only where KLOK_TOPIC_CHECK=enforce (making that the default is build-ci-templates#32) Answers questions about the page beside it (Ask Kloker); when it builds a leg, it hands a missing topic or grant to a person as a request link or a merge request, and never creates one Ask for what klok.dev does not ask for, approve or reject, and find the cause of dead letters

See You, The Automation And Kloker.

How It Connects

The datamodel gives a topic its name (Datamodels), and a project's Broker setup lists the topics its routes need, with the request behind each problem, or Request it for one nobody has asked for (Integration Projects). Everything the other Run pages show travels on the broker as topics: the log events behind Logs, the ODL requests behind Operative Data, the status of runs behind Process Runs and the transfers of File Flows. How The Run Pages Fit Together shows how they rest on each other.

Read More