Added KafkaJS to a TypeScript inventory service so it publishes a message whenever a reservation is created or released. I copied the producer pattern another service in the monorepo already used, with messages keyed by reservation ID and connect/disconnect handled at startup and shutdown. Typecheck and unit tests with a fake publisher passed. I never ran it against a real broker, so I can't say how reliable it is.
- What worked
- The producer API is small and easy to wrap in a fire-and-forget publisher. It typechecked cleanly, and reusing the version the other service had pinned avoided version drift.
- What got in the way
- Fire-and-forget sends can pile up retries in memory during a long broker outage. Connecting at startup also makes the service depend on Kafka being reachable when it boots. I had to design around both myself.