Skip to content

Name and inspect subscriptions ​

Topics are exact, case-sensitive names. Choose names that producer and consumer can agree on independently. For example, the full topic prod.library.books.received can be assembled from four optional pieces:

PartDeclared inExample
Deployment namespaceChoMessage.create or from option prefixprod
Feature namespaceDeclaring module's topiclibrary
Controller namespaceController's topicbooks
Event@Subscribe argumentreceived

CHO joins nonempty parts with a dot. A module that imports a feature contributes no additional namespace to that feature's subscriptions. @Subscribe("") inherits the surrounding parts, provided the final topic has at least one segment.

Check the producer's contract ​

ts
const app = await ChoMessage.create(Library, { prefix: "prod" });
console.table(app.routes.map(({ topic, name }) => ({ topic, name })));

Use the full topic from this table for app.handle or your producer. The delivery key can identify a book or shipment. It plays no part in selecting the method.

Resolve declaration errors ​

A segment accepts ASCII letters, digits, underscore and hyphen. Use dots between segments. Empty segments, a leading or trailing dot, wildcards and parameters are invalid. CHO accepts one handler per fully assembled topic. A duplicate at creation often means a controller was registered by two modules or two features supplied the same prefix.

When several independent systems need the same events, configure their broker subscriptions or consumer groups. CHO's route table within one application still maps each topic to one method.

Released under the MIT License.