Events and calls

This page, for technical readers, describes how subscription and its console talk to the platform’s other services:

It describes the code of the dev branches of subscription and subscription-front; the other services’ consumers are taken from the Kafka messages architecture page of the platform documentation.

Overview

  • subscription writes to five topics: subscription_irrc_topic, tenant_lifecycle_topic, notification_topic, library_topic and ui_events_topic. It reads only ui_events_topic, to relay changes to the console.
  • The console (subscription-front) calls directly, from the browser and through the gateway, each service it administers: crawler, library, notification, referential, dpm. subscription is not a go-between, except for the URLs added to the common library.
  • The subscription service calls none of these services over HTTP: it reaches library and notification only through Kafka. Its only outgoing synchronous call is Keycloak’s admin API.

Kafka topics

Topic subscription Message types Key Read by
subscription_irrc_topic writes UPDATE_PLAN tenantId irrc, assistant, risk-app
tenant_lifecycle_topic writes TENANT_DELETED tenantId irrc, library, assistant, risk-app
notification_topic writes SEND_MAIL the user, tenant or support access request concerned notification
library_topic writes NEW_PUBLICATION, NEW_COMMON_FILE link or fileName library
ui_events_topic writes and reads writes SUPPORT_REQUEST_CHANGED; reads CRAWLER_RUN_CHANGED, LIBRARY_DOCUMENT_CHANGED, LIBRARY_EMBEDDINGS_CHANGED, LIBRARY_INDEX_CHANGED, DOCLING_QUEUE_CHANGED, SUPPORT_REQUEST_CHANGED messageType subscription, irrc, risk-app

Other services also write to some of these topics: crawler to library_topic, notification_topic and ui_events_topic, library to ui_events_topic, irrc and risk-app to notification_topic.

Each topic has its producer in the bus package: Producer (subscription_irrc_topic), TenantLifecycleProducer, NotificationProducer, LibraryProducer and UiEventProducer; the reader is UiEventsConsumer.

Messages

UPDATE_PLAN

A tenant’s memberships changed: a user’s plans or role in that tenant, a user taken out, suspended or given back access, a user disabled or enabled, or the tenant’s status or validity. The message names the tenant, never the user; it has no content.

irrc, assistant and risk-app then forget what they cache for that tenant (every tenant when the message names no readable one); irrc then reads the memberships again from subscription. See Tenant lifecycle and Rights.

TENANT_DELETED

A deleted tenant’s grace period is over and the purge has marked it deleted: every service erases what it holds for that tenant. The message is sent once, when the purge commits, and may arrive more than once: each reader must be able to handle it again without harm. tenantId is the tenant’s public id (the one the services store), never subscription’s primary key. See Purge.

SEND_MAIL

A mail ready to go: subscription renders the HTML itself, from the templates/mail/*.ftlh templates and the i18n/mail*.properties texts. The content holds subject, htmlContent and recipients, with no attachment. The notification service sends it, records it in its history, and refuses the whole mail when a recipient is outside the allowed domains. The mails themselves are described in Notifications.

NEW_PUBLICATION and NEW_COMMON_FILE

Documents for the common library, sent by a platform administrator:

  • NEW_PUBLICATION: a URL, one message per URL, sent by POST /api/v1/common-documents/urls (CommonDocumentResource). The content holds link only; library downloads the document and indexes it. The crawler sends the same message type for its publications;
  • NEW_COMMON_FILE: a whole file, base64-encoded in the message (fileName, contentType, content, metadata, always empty), sent by POST /api/v1/common-documents/upload. The console does not use this entry point: it uploads files straight to library (see Synchronous calls).

SUPPORT_REQUEST_CHANGED

A user’s support access request or grant changed: their applications reload their support banner without waiting for their periodic read. The content holds tenantId, realm and username. subscription reads it too, for the support console. See Support access.

Envelopes

Each topic has its JSON envelope. All carry schemaVersion at 1; readers read the fields by name, so an added field does not disturb them.

Field subscription_irrc_topic tenant_lifecycle_topic notification_topic library_topic ui_events_topic
messageType UPDATE_PLAN TENANT_DELETED SEND_MAIL NEW_PUBLICATION, NEW_COMMON_FILE the event type
schemaVersion 1 1 1 1 1
tenantId the tenant’s public id the tenant’s public id — — — (inside content when there is one)
content — — the mail the document the event
deletedAt — the instant of the purge — — —

Classes: GenericProducerMessage, TenantLifecycleMessage, NotificationMessage (with MailMessage), LibraryMessage (with PublicationContent or CommonFileContent) and UiEventMessage (with SupportRequestChangedContent), in bus/message.

{"tenantId":"11111111-1111-1111-1111-111111111111","messageType":"UPDATE_PLAN","schemaVersion":1}
{"tenantId":"12359bb8-b120-11ed-afa1-0242ac120005","messageType":"TENANT_DELETED",
 "deletedAt":"2026-11-04T03:30:00.123456Z","schemaVersion":1}
{"messageType":"NEW_PUBLICATION","schemaVersion":1,"content":{"link":"https://www.example.com/doc.pdf"}}
{"messageType":"SUPPORT_REQUEST_CHANGED",
 "content":{"tenantId":"12359bb8-b120-11ed-afa1-0242ac120005","realm":"bpi","username":"s.bassin"},
 "schemaVersion":1}
Warning

The message type names and the envelope fields are the contract between the services. A renamed or removed type fails no compilation: it breaks reading in the other services, at runtime. Any change is decided together with the list of readers to ship in the same window.

Delivery guarantees

Each producer waits for the broker’s acknowledgement, at most application.kafka.send-timeout (10 seconds by default, each environment’s value coming from Consul). What happens on a failure depends on the message:

Message When it is sent On a failure
UPDATE_PLAN Inside the change’s transaction, once the change is written The change is rolled back and the request fails: a rights removal is never recorded without irrc being told.
TENANT_DELETED Inside the purge’s transaction, after its UPDATE_PLAN The purge is rolled back.
SEND_MAIL Once the change is committed The failure is logged; the change stays. For contract-end reminders, the failure rolls back the reminder’s record, and it is tried again at the next run.
NEW_PUBLICATION, NEW_COMMON_FILE During the administrator’s request The request fails, with the error error.messageTooLarge for a message too large, error.unknown otherwise.
SUPPORT_REQUEST_CHANGED Once the change is committed The failure is logged and the message dropped: the applications catch up at their periodic read.

The broker lets only dedicated Kafka users write notification_topic. NotificationProducer therefore connects with its own credentials, application.notification.kafka-username and application.notification.kafka-password; without them, it says so once at startup and no mail goes out. The other topics use the shared Kafka user.

An uploaded file travels whole in one message: file uploads are limited to 50 MB, and the producer’s message size to 75,000,000 bytes (a 50 MB file is about 67 MB once base64-encoded).

The console’s live updates

The console opens, per browser tab, a server-sent events (SSE) stream on subscription: GET /api/v1/events (text/event-stream, classes EventResource and SseHub of the sse package). The events are invalidations: they say “this changed, read it again”; the page concerned then reads its data again through the API, which checks the rights.

Where the events come from

UiEventsConsumer reads ui_events_topic and turns each message it knows into a browser event. Each subscription instance reads the topic in a group of its own (subscription-ui-events-<uuid>), from the latest messages: every instance sees every event and relays it to the browsers it serves. Nothing is retried or set aside: an unreadable message is skipped. The application.kafka.ui-events.auto-startup property can keep this reader from starting.

Kafka message Event sent (nature) Data Screen that reads again
CRAWLER_RUN_CHANGED CrawlerRunChanged runId Crawler, the runs
LIBRARY_DOCUMENT_CHANGED (common documents only) LibraryDocumentChanged documentId Library, the list of documents
LIBRARY_EMBEDDINGS_CHANGED LibraryEmbeddingsChanged — Library, the embeddings
LIBRARY_INDEX_CHANGED LibraryIndexChanged — Library, the search index
DOCLING_QUEUE_CHANGED DoclingQueueChanged — Crawler, the Docling tab
SUPPORT_REQUEST_CHANGED SupportAccessChanged tenantId (platform administrators only) Support console

An id at null means several items changed: the page reads the whole list again. Messages of an unknown type, and those about the tenants’ own documents, are not relayed.

The stream

  • Each frame is a message event whose data is a JSON object {"nature": …, …}.
  • A stream’s first frame is {"nature":"Connected"}: the console then knows it may have missed events and reads the open pages again.
  • A ping comment goes out every 20 seconds, well under the ingress’ 60-second read timeout.
  • A stream is closed after 30 minutes; the browser reconnects.
  • The same event received several times within 500 milliseconds goes out once.
  • A failed send closes that stream only.

Two audiences receive the stream:

  • platform administrators get every event, with its ids;
  • the support console’s other users (support members, tenant administrators) get only SupportAccessChanged, without the tenant, so that a stream never tells them about a tenant they do not administer.

On the console’s side

The console broadcasts each event as event.<nature>; each page listens to those that concern it and to event.Connected. After a cut, it tries to connect again, with at most 60 seconds between two attempts, including after a 401 or 403 refusal.

A dot in the top bar shows the stream’s state: green, “Live updates: connected”; orange after 5 seconds down, “Live updates: reconnecting”; red after a minute, “Live updates interrupted — data refreshes every 30 s”.

The pages do not rely on the stream alone: they also read again on their own while some work is in progress.

Screen Periodic read
Crawler, runs every 30 s while a run is going
Crawler, summaries every 10 s while a summary is in progress
Crawler, Docling every 10 s while the tab is open
Library, documents every 30 s while a document is queued, converting or embedding
Library, embeddings and search index every 30 s while some work runs
Reference data, sources every 3 s while an update runs (no stream)
DPM Kafka work every 5 s while the tab is visible (no stream)

Synchronous calls

The console calls each service from the browser, through the gateway: the address is the gateway’s, followed by the service’s name and the path, and the call carries the user’s token. The service called decides what the user may do: crawler and notification, for example, keep their API for platform administrators and the internal service account, and notification keeps resending a mail for administrators alone.

Caller → service Entry points Screen
console → crawler /api/v1/publications (list, POST /send-to-library); /api/v1/feeds (list, create, update, delete, POST /test); /api/v1/crawler/sources (list, PUT /{id}); /api/v1/crawler/settings and /api/v1/crawler/schedule (read, PUT); /api/v1/crawler/runs (list, POST with an optional source, /{id}, /{id}/publications); /api/v1/digest-recipients (list, create, update, delete, /sources, POST /{id}/test); /api/v1/digests (list, /next, /{day}, POST /{day}/resend) Crawler
console → library /api/v1/crawler-summaries (read by documentIds, POST); /api/v1/documents/markdown/queue Crawler, summaries and Docling
console → library /api/v1/documents/common (list, DELETE /{id}, POST of a list of ids to delete, POST /upload, GET /{id}/markdown, POST /{id}/markdown/retry, POST /markdown/retry-missing, POST /{id}/embeddings, POST /embeddings/selection, POST /{id}/indexing); /api/v1/documents/common/embeddings (status, POST); /api/v1/documents/index/rebuild (status, POST) Library
console → subscription POST /api/v1/common-documents/urls Library, URLs
console → notification /api/v1/mails (list, /{id}, /{id}/attachments/{attachment}, POST /{id}/resend) Notifications
console → referential /api/v1/structure/dataflow, /api/v1/structure/datastructure; /api/v1/bundles (POST of a zip, PUT and DELETE /{agency}/{id}/{version}); /api/v1/loader/cubes (list, POST, PUT and DELETE /{id}, /{id}/runs, POST /{id}/refresh, POST /{id}/upload); POST /api/v1/loader/refresh Reference data
console → dpm GET /api/v1/admin/kafka-work DPM Kafka work
console → subscription GET /api/v1/tenants (tenant names); GET /api/v1/events (stream) DPM Kafka work; every page
subscription → Keycloak Each realm’s admin API, through its service client (subscription-provisioning by default): disable or enable an account (disabling ends its sessions), read the logins and impersonations, check an account before a support access Identities, Support access
Note

The common library’s URLs go through subscription, which puts them on library_topic; files go straight to library. A URL sent is therefore in the broker’s hands, a file sent in library’s.