Part III and Part IV chapters as written during the course

The two chapter files are not yet in the profiles' chapter lists, so the
built book does not show them yet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
MatsuneMikuroiandClaude Opus 5.5 committed 2026-10-06 07:10:37 +02:00
1 parent f7fa60ba81
commit 54338b3ea2
2 files changed
+385

No files matched your search

+224
View File
@@ -0,0 +1,224 @@
# [Part III — Make it actually distributed]{.en}[Partie III — Le rendre réellement distribué]{.fr}[Teil III — Es wirklich verteilen]{.de} {#sec-part-iii}
<!-- MULTILINGUAL: see the comment at the top of index.qmd.
A figure for the two-machine replication is still to be drawn; the
measurements below carry the argument in the meantime. -->
::: {.en}
Five processes on one computer still share one filesystem. Steps 19 to 27 put them on two machines, replicate the message board between them with Syncthing, measure what that costs, and then break a mediator on purpose. By the end, the mediators' price is a number rather than an opinion.
:::
::: {.fr}
Cinq processus sur un seul ordinateur partagent encore un même système de fichiers. Les étapes 19 à 27 les répartissent sur deux machines, répliquent le tableau de messages entre elles avec Syncthing, mesurent ce que cela coûte, puis cassent délibérément un médiateur. À la fin, le prix des médiateurs est un chiffre, non une opinion.
:::
::: {.de}
Fünf Prozesse auf einem Rechner teilen immer noch ein Dateisystem. Die Schritte 19 bis 27 verteilen sie auf zwei Maschinen, replizieren das Nachrichtenbrett mit Syncthing zwischen ihnen, messen die Kosten und zerbrechen dann absichtlich einen Vermittler. Am Ende ist der Preis der Vermittler eine Zahl und keine Meinung.
:::
## [Syncthing replicates; it does not deliver]{.en}[Syncthing réplique ; il ne distribue pas]{.fr}[Syncthing repliziert; es liefert nicht aus]{.de} {#sec-syncthing-not-a-broker}
::: {.en}
Syncthing keeps a directory replicated between machines. That is all it is asked to do here. It knows nothing about Intent, Status, Event, ROT13 or mediators, and it has no concept of a consumer: no subscriptions, no topics, no delivery guarantees, no notion that anybody is waiting.
The trigger is still ours. Each service runs its own `WatchService` on a **local** directory; Syncthing only makes files appear there. That is why none of the three services changed a single line when the system became distributed.
Two consequences follow, and both show up later as observations rather than warnings:
- replication is **asynchronous** — the `.tmp → .msg` rename is atomic on each machine separately, and nothing promises ordering or atomicity between machines;
- the filesystem is a serious transport with its own strengths: files can be large, replicas survive a reboot, and every message is readable with `cat`.
:::
::: {.fr}
Syncthing maintient un répertoire répliqué entre plusieurs machines. C'est tout ce qu'on lui demande ici. Il ne sait rien d'Intent, de Status, d'Event, de ROT13 ni des médiateurs, et il n'a aucune notion de consommateur : pas d'abonnement, pas de sujet, aucune garantie de livraison, aucune idée que quelqu'un attend.
Le déclencheur reste le nôtre. Chaque service exécute son propre `WatchService` sur un répertoire **local** ; Syncthing fait seulement apparaître les fichiers à cet endroit. C'est pourquoi aucun des trois services n'a changé d'une ligne lorsque le système est devenu distribué.
Deux conséquences en découlent, et toutes deux apparaîtront comme des observations plutôt que comme des avertissements :
- la réplication est **asynchrone** — le renommage `.tmp → .msg` est atomique sur chaque machine séparément, et rien ne promet d'ordre ni d'atomicité entre machines ;
- le système de fichiers est un transport sérieux, avec ses forces : les fichiers peuvent être gros, les répliques survivent à un redémarrage, et chaque message se lit avec `cat`.
:::
::: {.de}
Syncthing hält ein Verzeichnis zwischen Maschinen repliziert. Mehr wird hier nicht verlangt. Es weiss nichts von Intent, Status, Event, ROT13 oder Vermittlern, und es kennt keinen Konsumenten: keine Abonnements, keine Topics, keine Lieferzusagen, keine Vorstellung davon, dass jemand wartet.
Der Auslöser bleibt unser eigener. Jeder Dienst betreibt seinen eigenen `WatchService` auf einem **lokalen** Verzeichnis; Syncthing lässt die Dateien dort nur erscheinen. Deshalb musste keiner der drei Dienste eine Zeile ändern, als das System verteilt wurde.
Daraus folgen zwei Dinge, die später als Beobachtung und nicht als Warnung auftreten:
- Replikation ist **asynchron** — das Umbenennen `.tmp → .msg` ist auf jeder Maschine einzeln atomar, und nichts verspricht Reihenfolge oder Atomarität zwischen Maschinen;
- das Dateisystem ist ein ernstzunehmender Transport mit eigenen Stärken: Dateien dürfen gross sein, Replikate überleben einen Neustart, und jede Nachricht lässt sich mit `cat` lesen.
:::
## [Test one layer at a time]{.en}[Tester une couche à la fois]{.fr}[Eine Schicht auf einmal prüfen]{.de} {#sec-one-layer}
::: {.en}
Before any Java touched the replicated folder, the dullest possible test ran first: write `hello.txt` on one machine, confirm it appears on the other, delete it, confirm the deletion travels back. Both directions worked.
That order matters. When the distributed run later failed, the question "is it replication or is it my program?" had already been answered for the transport, and the search could start one layer up.
:::
::: {.fr}
Avant que le moindre programme Java ne touche au dossier répliqué, le test le plus ennuyeux possible a été fait d'abord : écrire `hello.txt` sur une machine, vérifier qu'il apparaît sur l'autre, le supprimer, vérifier que la suppression revient. Les deux sens fonctionnent.
Cet ordre compte. Quand l'exécution distribuée a échoué plus tard, la question « est-ce la réplication ou mon programme ? » était déjà tranchée pour le transport, et la recherche pouvait commencer une couche plus haut.
:::
::: {.de}
Bevor irgendein Java-Programm den replizierten Ordner berührte, lief der langweiligste denkbare Test: `hello.txt` auf einer Maschine schreiben, prüfen, dass es auf der anderen erscheint, es löschen, prüfen, dass die Löschung zurückkommt. Beide Richtungen funktionierten.
Diese Reihenfolge ist wichtig. Als der verteilte Lauf später scheiterte, war die Frage „Replikation oder mein Programm?" für den Transport schon beantwortet, und die Suche konnte eine Schicht höher beginnen.
:::
## [What one keystroke costs]{.en}[Ce que coûte une frappe]{.fr}[Was ein Tastendruck kostet]{.de} {#sec-keystroke-cost}
::: {.en}
With the sensor on one machine and the mediators, ROT13 and the actuator on the other, one typed line produced **four** `.msg` files, one per mailbox:
| mailbox | content | timestamp inside |
|---|---|---|
| `consoleIn/outbox` | `Hello World` | 23:02:05.315 |
| `rot13/inbox` | `Hello World` | 23:02:05.315 |
| `rot13/outbox` | `Uryyb Jbeyq` | 23:02:13.471 |
| `consoleOut/inbox` | `Uryyb Jbeyq` | 23:02:13.471 |
The repeated timestamps are the evidence that two of those four publications are **pure copies**: the mediators republish the message unchanged, timestamp included. They compute `identity(x) = x`, as separate distributed processes.
The timing, taken from the four files' modification times on one machine so that no clock skew enters: the sensor's file appears at `01:02:05.432`, the other three at `01:02:13.460`, `.504` and `.532` — **8.10 s** later, and within **72 ms of each other**. So the chain's own work took milliseconds; the eight seconds are Syncthing's propagation. The same chain, run entirely on one machine, completes in about 24 ms.
:::
::: {.fr}
Avec le capteur sur une machine et les médiateurs, ROT13 et l'actionneur sur l'autre, une ligne tapée a produit **quatre** fichiers `.msg`, un par boîte :
| boîte | contenu | horodatage interne |
|---|---|---|
| `consoleIn/outbox` | `Hello World` | 23:02:05.315 |
| `rot13/inbox` | `Hello World` | 23:02:05.315 |
| `rot13/outbox` | `Uryyb Jbeyq` | 23:02:13.471 |
| `consoleOut/inbox` | `Uryyb Jbeyq` | 23:02:13.471 |
Les horodatages répétés prouvent que deux de ces quatre publications sont de **pures copies** : les médiateurs republient le message inchangé, horodatage compris. Ils calculent `identity(x) = x`, sous forme de processus distribués distincts.
Le temps, mesuré sur les dates de modification des quatre fichiers d'une seule machine pour qu'aucun décalage d'horloge n'intervienne : le fichier du capteur apparaît à `01:02:05.432`, les trois autres à `01:02:13.460`, `.504` et `.532` — **8,10 s** plus tard, et à **72 ms** l'un de l'autre. Le travail propre de la chaîne a donc pris des millisecondes ; les huit secondes sont la propagation de Syncthing. La même chaîne, exécutée entièrement sur une machine, termine en 24 ms environ.
:::
::: {.de}
Mit dem Sensor auf einer Maschine und den Vermittlern, ROT13 und dem Aktor auf der anderen erzeugte eine getippte Zeile **vier** `.msg`-Dateien, eine pro Postfach:
| Postfach | Inhalt | Zeitstempel darin |
|---|---|---|
| `consoleIn/outbox` | `Hello World` | 23:02:05.315 |
| `rot13/inbox` | `Hello World` | 23:02:05.315 |
| `rot13/outbox` | `Uryyb Jbeyq` | 23:02:13.471 |
| `consoleOut/inbox` | `Uryyb Jbeyq` | 23:02:13.471 |
Die wiederholten Zeitstempel belegen, dass zwei dieser vier Veröffentlichungen **reine Kopien** sind: die Vermittler veröffentlichen die Nachricht unverändert erneut, Zeitstempel eingeschlossen. Sie berechnen `identity(x) = x`, als eigene verteilte Prozesse.
Die Zeiten, gemessen an den Änderungszeiten der vier Dateien auf einer Maschine, damit keine Uhrendifferenz hineinspielt: die Datei des Sensors erscheint um `01:02:05.432`, die drei anderen um `01:02:13.460`, `.504` und `.532` — **8,10 s** später und innerhalb von **72 ms** zueinander. Die eigentliche Arbeit der Kette dauerte also Millisekunden; die acht Sekunden sind Syncthings Verbreitung. Dieselbe Kette, vollständig auf einer Maschine, braucht etwa 24 ms.
:::
## [Break a mediator]{.en}[Casser un médiateur]{.fr}[Einen Vermittler zerbrechen]{.de} {#sec-break-a-mediator}
::: {.en}
Stop the first mediator and type two lines. ConsoleIn is alive, ROT13 is alive, ConsoleOut is alive, Syncthing is alive — and the business flow is dead. The two lines pile up in `consoleIn/outbox`; nothing moves past it. The mediators are part of the availability chain.
Then restart the mediator. **Nothing is delivered.** `FileMessageBoard.watch` registers a directory for `ENTRY_CREATE` and blocks in `watcher.take()`; it never lists what is already there. The two files are still on disk, in both replicas — so no data was lost. What has no memory is the *subscription*.
That distinction is worth keeping: **the messages survived, the delivery did not.** A broker answers this with session state and retained messages; in our own code it would be one line — list the existing `.msg` files before entering the watch loop — which the material deliberately does not write yet.
:::
::: {.fr}
Arrêtez le premier médiateur et tapez deux lignes. ConsoleIn est vivant, ROT13 est vivant, ConsoleOut est vivant, Syncthing est vivant — et le flux métier est mort. Les deux lignes s'accumulent dans `consoleIn/outbox` ; rien ne va plus loin. Les médiateurs font partie de la chaîne de disponibilité.
Redémarrez ensuite le médiateur. **Rien n'est livré.** `FileMessageBoard.watch` enregistre un répertoire pour `ENTRY_CREATE` et se bloque dans `watcher.take()` ; il ne liste jamais ce qui est déjà là. Les deux fichiers sont toujours sur le disque, dans les deux répliques : aucune donnée n'a été perdue. Ce qui n'a pas de mémoire, c'est l'*abonnement*.
La distinction mérite d'être retenue : **les messages ont survécu, la livraison non.** Un courtier répond à cela par l'état de session et les messages retenus ; dans notre propre code, ce serait une ligne — lister les fichiers `.msg` existants avant d'entrer dans la boucle d'observation — que le matériel se garde volontairement d'écrire pour l'instant.
:::
::: {.de}
Halten Sie den ersten Vermittler an und tippen Sie zwei Zeilen. ConsoleIn lebt, ROT13 lebt, ConsoleOut lebt, Syncthing lebt — und der Geschäftsfluss ist tot. Die zwei Zeilen stapeln sich in `consoleIn/outbox`; weiter kommt nichts. Die Vermittler gehören zur Verfügbarkeitskette.
Starten Sie den Vermittler neu. **Nichts wird ausgeliefert.** `FileMessageBoard.watch` registriert ein Verzeichnis für `ENTRY_CREATE` und blockiert in `watcher.take()`; es listet nie, was schon da ist. Die zwei Dateien liegen weiter auf der Platte, in beiden Replikaten — es ging also nichts verloren. Kein Gedächtnis hat das *Abonnement*.
Diese Unterscheidung lohnt sich: **die Nachrichten überlebten, die Auslieferung nicht.** Ein Broker antwortet darauf mit Sitzungszustand und retained messages; im eigenen Code wäre es eine Zeile — die vorhandenen `.msg`-Dateien auflisten, bevor die Beobachtungsschleife beginnt — die das Material bewusst noch nicht schreibt.
:::
## [The mediator becomes an ordinary service]{.en}[Le médiateur devient un service ordinaire]{.fr}[Der Vermittler wird ein gewöhnlicher Dienst]{.de} {#sec-configurable-mediator}
::: {.en}
Before removing the mediators, one asymmetry gets removed: the services receive their *work* as messages, while the mediator received its *route* as shell arguments. So the mediator is given only a name, `ConfigurableMediator mediator1`, from which it derives one permanent control mailbox, `mediators/mediator1/inbox`, and the route arrives as a message:
```text
ROUTE
consoleIn/outbox
rot13/inbox
```
`from` and `to` travel in **one** message on purpose: as two, the mediator would briefly hold a new source with the old destination and forward to the wrong place. A route is one fact, and one fact belongs in one message.
A short-lived orchestrator publishes both routes and exits, so the topology is visible in one place and is **not** in the data path. Running it after the services, and typing a line before it, shows both halves at once: the early line is stranded, the later one flows.
What improved: the mediator now has an identity, takes configuration through its own inbox, keeps a generic capability, and gets its topology from an orchestrator. What did not improve: the data path. It is still `event → mediator → copied event`, still a process in the availability chain, still copying every message without adding meaning. And this version accepts exactly **one** route: `waitForRoute(...)` returns, then the mediator enters `watch(route.from(), …)` and never reads its control inbox again. Live rewiring is not promised, because one blocking `watch` cannot serve a control inbox and a source at the same time — the reason a subscription helper appears later.
:::
::: {.fr}
Avant de supprimer les médiateurs, une asymétrie disparaît : les services reçoivent leur *travail* sous forme de messages, alors que le médiateur recevait sa *route* en arguments de shell. On ne lui donne donc qu'un nom, `ConfigurableMediator mediator1`, dont il dérive une boîte de contrôle permanente, `mediators/mediator1/inbox`, et la route arrive comme message :
```text
ROUTE
consoleIn/outbox
rot13/inbox
```
`from` et `to` voyagent dans **un seul** message, volontairement : en deux, le médiateur combinerait brièvement une nouvelle source avec l'ancienne destination et transmettrait au mauvais endroit. Une route est un seul fait, et un fait tient dans un message.
Un orchestrateur éphémère publie les deux routes puis s'arrête : la topologie est visible en un seul endroit et n'est **pas** dans le chemin des données. Le lancer après les services, en ayant tapé une ligne avant, montre les deux moitiés d'un coup : la ligne précoce reste bloquée, la suivante circule.
Ce qui s'améliore : le médiateur a une identité, reçoit sa configuration par sa propre boîte, garde une capacité générique et tient sa topologie d'un orchestrateur. Ce qui ne s'améliore pas : le chemin des données. Il reste `event → médiateur → copie de l'event`, toujours un processus dans la chaîne de disponibilité, qui copie chaque message sans rien y ajouter. Et cette version accepte exactement **une** route : `waitForRoute(...)` retourne, puis le médiateur entre dans `watch(route.from(), …)` et ne lit plus jamais sa boîte de contrôle. Le recâblage à chaud n'est pas promis, car un `watch` bloquant ne peut pas servir à la fois une boîte de contrôle et une source — d'où l'aide à l'abonnement qui apparaît plus tard.
:::
::: {.de}
Bevor die Vermittler verschwinden, fällt eine Asymmetrie weg: die Dienste erhalten ihre *Arbeit* als Nachrichten, der Vermittler erhielt seine *Route* als Shell-Argumente. Er bekommt daher nur einen Namen, `ConfigurableMediator mediator1`, aus dem er ein dauerhaftes Steuerpostfach ableitet, `mediators/mediator1/inbox`, und die Route kommt als Nachricht:
```text
ROUTE
consoleIn/outbox
rot13/inbox
```
`from` und `to` reisen absichtlich in **einer** Nachricht: als zwei hielte der Vermittler kurz eine neue Quelle mit dem alten Ziel und leitete an die falsche Stelle weiter. Eine Route ist ein Fakt, und ein Fakt gehört in eine Nachricht.
Ein kurzlebiger Orchestrator veröffentlicht beide Routen und endet, damit die Topologie an einer Stelle sichtbar ist und **nicht** im Datenpfad liegt. Startet man ihn nach den Diensten und hat vorher eine Zeile getippt, zeigen sich beide Hälften auf einmal: die frühe Zeile bleibt liegen, die späte läuft durch.
Was besser wird: der Vermittler hat eine Identität, nimmt Konfiguration über sein eigenes Postfach, behält eine generische Fähigkeit und bezieht seine Topologie von einem Orchestrator. Was nicht besser wird: der Datenpfad. Er bleibt `event → Vermittler → kopiertes event`, weiter ein Prozess in der Verfügbarkeitskette, der jede Nachricht ohne Bedeutungsgewinn kopiert. Und diese Fassung nimmt genau **eine** Route an: `waitForRoute(...)` kehrt zurück, dann betritt der Vermittler `watch(route.from(), …)` und liest sein Steuerpostfach nie wieder. Umverdrahten im Betrieb wird nicht versprochen, weil ein blockierendes `watch` nicht gleichzeitig ein Steuerpostfach und eine Quelle bedienen kann — der Grund für die Abonnement-Hilfe später.
:::
## [What part III moved]{.en}[Ce que la partie III a déplacé]{.fr}[Was Teil III verschoben hat]{.de} {#sec-part-iii-result}
::: {.en}
| stage | where the topology lives | in the data path? |
|---|---|---|
| step 18 | the operator's command lines | the mediators are |
| step 27 | an orchestrator, published as Intent | the mediators still are |
The question the part ends on is therefore sharp rather than rhetorical: **why can't the service interested in the data simply listen to it itself?**
:::
::: {.fr}
| étape | où vit la topologie | dans le chemin des données ? |
|---|---|---|
| étape 18 | les lignes de commande de l'opérateur | les médiateurs y sont |
| étape 27 | un orchestrateur, publiée comme Intent | les médiateurs y sont encore |
La question sur laquelle se referme la partie est donc précise et non rhétorique : **pourquoi le service intéressé par la donnée ne pourrait-il pas l'écouter lui-même ?**
:::
::: {.de}
| Stufe | wo die Topologie liegt | im Datenpfad? |
|---|---|---|
| Schritt 18 | die Befehlszeilen des Bedieners | die Vermittler sind es |
| Schritt 27 | ein Orchestrator, als Intent veröffentlicht | die Vermittler sind es weiterhin |
Die Frage, mit der der Teil schliesst, ist daher scharf und nicht rhetorisch: **warum kann der Dienst, der sich für die Daten interessiert, sie nicht selbst hören?**
:::
+161
View File
@@ -0,0 +1,161 @@
# [Part IV — Rewind]{.en}[Partie IV — Rembobinage]{.fr}[Teil IV — Zurückspulen]{.de} {#sec-part-iv}
<!-- MULTILINGUAL: see the comment at the top of index.qmd. -->
::: {.en}
Steps 28 to 34 go back to one JVM on purpose. With no replication delay and no five-terminal setup, the only thing that can change is who knows whom — so the idea can be tried in seconds instead of in a distributed debugging session.
:::
::: {.fr}
Les étapes 28 à 34 reviennent volontairement à une seule JVM. Sans délai de réplication ni cinq terminaux, la seule chose qui peut changer est qui connaît qui — l'idée s'essaie donc en quelques secondes plutôt qu'au cours d'une séance de débogage distribué.
:::
::: {.de}
Die Schritte 28 bis 34 kehren absichtlich zu einer JVM zurück. Ohne Replikationsverzögerung und ohne fünf Terminals kann sich nur ändern, wer wen kennt — die Idee lässt sich also in Sekunden ausprobieren statt in einer verteilten Fehlersuche.
:::
## [The obvious shortcut, and its trap]{.en}[Le raccourci évident, et son piège]{.fr}[Die naheliegende Abkürzung und ihre Falle]{.de} {#sec-the-trap}
::: {.en}
If the first mediator only copies messages, delete it and let ROT13 read the source itself:
```java
listen("consoleIn.outbox");
```
The mediator is gone. But ask the recurring question: ROT13 now contains the name of ConsoleIn's mailbox. The topology moved out of the mediator and **into the service**. As the material puts it: "We removed the mediator… and put topology back into the service. *Oops.*"
:::
::: {.fr}
Si le premier médiateur ne fait que copier des messages, supprimons-le et laissons ROT13 lire la source lui-même :
```java
listen("consoleIn.outbox");
```
Le médiateur a disparu. Mais posons la question récurrente : ROT13 contient désormais le nom de la boîte de ConsoleIn. La topologie a quitté le médiateur pour entrer **dans le service**. Comme le dit le matériel : « nous avons supprimé le médiateur… et remis la topologie dans le service. *Oups.* »
:::
::: {.de}
Wenn der erste Vermittler nur Nachrichten kopiert: löschen wir ihn und lassen ROT13 die Quelle selbst lesen:
```java
listen("consoleIn.outbox");
```
Der Vermittler ist weg. Doch die wiederkehrende Frage: ROT13 enthält jetzt den Namen von ConsoleIns Postfach. Die Topologie ist aus dem Vermittler **in den Dienst** gewandert. Im Wortlaut des Materials: „Wir haben den Vermittler entfernt … und die Topologie zurück in den Dienst gelegt. *Hoppla.*"
:::
## [Capability is not topology]{.en}[La capacité n'est pas la topologie]{.fr}[Fähigkeit ist nicht Topologie]{.de} {#sec-capability-vs-topology}
::: {.en}
ROT13 may know two things: *I can transform text*, and *I am capable of listening for compatible text messages*. It may **not** know *my input always comes from consoleIn.outbox* — that is deployment topology.
So the name is not compiled in; it arrives at runtime:
```text
TOPIC consoleIn.outbox
```
ROT13 learns its wiring from data. Note who sends it: in `DynamicQueueRot13.java` it is `main()` that publishes both `TOPIC` messages — a configurator, outside the data path, in the role the orchestrator played before. It cannot be ConsoleIn: if ConsoleIn told ROT13 what to subscribe to, ConsoleIn would have to know ROT13 exists, and the topology would simply have moved into a different capability.
:::
::: {.fr}
ROT13 peut savoir deux choses : *je sais transformer du texte* et *je suis capable d'écouter des messages texte compatibles*. Il ne doit **pas** savoir *mon entrée vient toujours de consoleIn.outbox* — c'est de la topologie de déploiement.
Le nom n'est donc pas compilé ; il arrive à l'exécution :
```text
TOPIC consoleIn.outbox
```
ROT13 apprend son câblage par la donnée. Notez qui l'envoie : dans `DynamicQueueRot13.java`, c'est `main()` qui publie les deux messages `TOPIC` — un configurateur, hors du chemin des données, dans le rôle qu'occupait l'orchestrateur. Ce ne peut pas être ConsoleIn : s'il disait à ROT13 à quoi s'abonner, il devrait savoir que ROT13 existe, et la topologie aurait seulement changé de capacité d'accueil.
:::
::: {.de}
ROT13 darf zwei Dinge wissen: *ich kann Text transformieren* und *ich kann auf kompatible Textnachrichten hören*. Es darf **nicht** wissen: *meine Eingabe kommt immer aus consoleIn.outbox* — das ist Deployment-Topologie.
Der Name ist daher nicht einkompiliert, er kommt zur Laufzeit:
```text
TOPIC consoleIn.outbox
```
ROT13 lernt seine Verdrahtung aus Daten. Wer sie sendet, ist wichtig: in `DynamicQueueRot13.java` veröffentlicht `main()` beide `TOPIC`-Nachrichten — ein Konfigurator ausserhalb des Datenpfads, in der Rolle des früheren Orchestrators. ConsoleIn kann es nicht sein: sagte ConsoleIn ROT13, was es abonnieren soll, müsste es wissen, dass ROT13 existiert — die Topologie wäre nur in eine andere Fähigkeit gewandert.
:::
## [What changes in the code]{.en}[Ce qui change dans le code]{.fr}[Was sich im Code ändert]{.de} {#sec-dynamic-mechanics}
::: {.en}
`listen(...)` is nothing exotic: a virtual thread that repeatedly calls `take()` on one of the same queues. `subscribe(...)` starts one such thread per subscribed name. The consequence is visible in the mailboxes:
- ROT13 takes **straight from `consoleIn.outbox`** — the name it was told;
- `rot13.inbox` is no longer a payload mailbox. It carries control messages, and ROT13's loop reads it to decide whether a message is a `TOPIC` to act on.
Nothing writes into `rot13.inbox` to move data anymore. The mailbox did not disappear; it changed job, from carrying payload to carrying Intent.
One observation from running it: after `Ctrl+D`, output stops but the program stays up. Nothing was interrupted — `runConsoleIn` returns on end of input, so the **producer** is gone, while both subscriber threads sit blocked in `take()` on sources that will never publish again. The JVM stays alive because `main` ends with `Thread.currentThread().join()`. "The flow stopped" always has to be traced to *which* participant stopped.
:::
::: {.fr}
`listen(...)` n'a rien d'exotique : un thread virtuel qui appelle `take()` en boucle sur l'une des mêmes files. `subscribe(...)` démarre un tel thread par nom abonné. La conséquence se voit dans les boîtes :
- ROT13 retire **directement de `consoleIn.outbox`** — le nom qu'on lui a transmis ;
- `rot13.inbox` n'est plus une boîte de charge utile. Elle porte des messages de contrôle, et la boucle de ROT13 la lit pour décider si un message est un `TOPIC` à appliquer.
Plus rien n'écrit dans `rot13.inbox` pour déplacer des données. La boîte n'a pas disparu : elle a changé de métier, de la charge utile vers l'Intent.
Une observation à l'exécution : après `Ctrl+D`, la sortie s'arrête mais le programme reste en vie. Rien n'a été interrompu — `runConsoleIn` retourne à la fin de l'entrée, donc le **producteur** a disparu, tandis que les deux threads abonnés restent bloqués dans `take()` sur des sources qui ne publieront plus. La JVM survit parce que `main` finit par `Thread.currentThread().join()`. « Le flux s'est arrêté » doit toujours être ramené à *quel* participant s'est arrêté.
:::
::: {.de}
`listen(...)` ist nichts Exotisches: ein virtueller Thread, der wiederholt `take()` auf einer derselben Warteschlangen aufruft. `subscribe(...)` startet einen solchen Thread pro abonniertem Namen. Die Folge ist in den Postfächern sichtbar:
- ROT13 nimmt **direkt aus `consoleIn.outbox`** — dem Namen, den es erhalten hat;
- `rot13.inbox` ist kein Nutzlast-Postfach mehr. Es trägt Steuernachrichten, und ROT13s Schleife liest es, um zu entscheiden, ob eine Nachricht ein anzuwendendes `TOPIC` ist.
Nichts schreibt mehr in `rot13.inbox`, um Daten zu bewegen. Das Postfach verschwand nicht; es wechselte die Aufgabe, von Nutzlast zu Intent.
Eine Beobachtung aus dem Lauf: nach `Ctrl+D` endet die Ausgabe, das Programm bleibt aber am Leben. Unterbrochen wurde nichts — `runConsoleIn` kehrt am Eingabeende zurück, der **Produzent** ist also weg, während beide Abonnenten-Threads in `take()` auf Quellen warten, die nie wieder veröffentlichen. Die JVM lebt weiter, weil `main` mit `Thread.currentThread().join()` endet. „Der Fluss stoppte" muss immer darauf zurückgeführt werden, *welcher* Beteiligte stoppte.
:::
## [`ROUTE` and `TOPIC` are Intent]{.en}[`ROUTE` et `TOPIC` sont de l'Intent]{.fr}[`ROUTE` und `TOPIC` sind Intent]{.de} {#sec-route-topic-intent}
::: {.en}
Apply two tests to `TOPIC consoleIn.outbox`. Does it describe something that happened? No. Something currently true? No. It says *please begin listening here* — desired behaviour, which is **Intent**. The mediator's `ROUTE` is the same kind of message: *please forward from here to there*.
One trap worth naming, because it is tempting in a defence: *publishing* an Intent is of course something that happened. Classification follows what the message says, not the fact that it exists.
And one condition, which returns later: the dynamic version is **not** automatically superior. It makes sense only if the consumer actually understands the producer's message contract.
```text
STATIC MEDIATED DYNAMIC DIRECT
Producer → Mediator → Consumer Intent → (Producer ──► Consumer)
```
:::
::: {.fr}
Appliquons deux tests à `TOPIC consoleIn.outbox`. Décrit-il quelque chose qui est arrivé ? Non. Quelque chose actuellement vrai ? Non. Il dit *commence à écouter ici* — un comportement souhaité, donc de l'**Intent**. Le `ROUTE` du médiateur est du même genre : *transmets d'ici à là*.
Un piège à nommer, car il est tentant dans une soutenance : *publier* un Intent est bien sûr quelque chose qui est arrivé. La classification suit ce que dit le message, pas le fait qu'il existe.
Et une condition, qui reviendra : la version dynamique n'est **pas** automatiquement supérieure. Elle n'a de sens que si le consommateur comprend vraiment le contrat de message du producteur.
```text
MÉDIÉ STATIQUE DIRECT DYNAMIQUE
Producteur → Médiateur → Consommateur Intent → (Producteur ──► Consommateur)
```
:::
::: {.de}
Zwei Tests für `TOPIC consoleIn.outbox`. Beschreibt es etwas, das geschehen ist? Nein. Etwas, das gerade gilt? Nein. Es sagt *beginne hier zu hören* — gewünschtes Verhalten, also **Intent**. Das `ROUTE` des Vermittlers ist dieselbe Art Nachricht: *leite von hier nach dort weiter*.
Eine Falle, die benannt gehört, weil sie in einer Verteidigung verlockt: ein Intent zu *veröffentlichen* ist natürlich etwas, das geschehen ist. Die Einordnung folgt dem, was die Nachricht sagt, nicht ihrer Existenz.
Und eine Bedingung, die wiederkommt: die dynamische Fassung ist **nicht** automatisch besser. Sie ergibt nur Sinn, wenn der Konsument den Nachrichtenvertrag des Produzenten wirklich versteht.
```text
STATISCH VERMITTELT DYNAMISCH DIREKT
Produzent → Vermittler → Konsument Intent → (Produzent ──► Konsument)
```
:::