02 / StreamForge

Java 21 · Spring Boot · Kafka · PostgreSQL

StreamForge

An accepted reading is committed before Kafka publishes it, and a second delivery does not apply twice.

The Spring Boot API writes telemetry and an outbox row in one PostgreSQL transaction. A publisher then sends the event at least once, and a worker records one processing receipt.

The public demo is a browser-local simulation of that pipeline. The Java, Kafka, and PostgreSQL services run locally through Docker Compose. The public site is not a hosted broker, database, or Spring Boot backend.

01 — The Engineering Problem

Accept the reading even when delivery is still ahead.

Telemetry has to survive a broker outage, a retry, and a duplicate delivery without losing the accepted reading or applying it twice.

  • Durable ingestion

    against a publish that can fail after the API has already answered

  • At-least-once delivery

    against a worker that must not record the same event twice

  • A poison payload

    against a source record that should stay unacknowledged until the dead letter is sent

  • Analytics on accepted rows

    against completion that happens later, on a separate receipt

02 — System Architecture

Persistence first. Publication second.

The API commits the accepted reading and the outbox row together. Kafka publication is a later step, so a broker outage does not roll back an already accepted event.

  1. API
  2. PostgreSQL
  3. Outbox
  4. Publisher
  5. Kafka
  6. Worker
  7. Receipt
  • Accept

    Ingestion checks the device, inserts the telemetry row, and inserts the outbox row inside one transaction.

  • Publish

    The publisher claims one pending outbox row with a lease token, then sends it to Kafka.

  • Process

    The worker compares the Kafka record with the stored reading and writes one receipt per event id.

  • Read

    Hour and day analytics read accepted telemetry. They do not wait for the worker receipt.

03 — Transactional Outbox

The reading and the outbox row commit together.

IngestionService.accept is transactional. A new event inserts the telemetry row and then the outbox row. If that transaction rolls back, neither row remains.

  • A repeated event id with the same canonical hash returns the existing acceptance.
  • The same event id with a different payload is rejected as a conflict.
  • Publication status stays pending until a later publisher cycle sends the row.
  • A broker failure after acceptance leaves the reading stored and the outbox row waiting.

04 — Idempotency & Reliability

Retries are safe. A changed payload is not.

Event identity is the event id plus the stored reading. Delivery is at-least-once: a crash after the broker acknowledgement can publish the same record again.

  • The publisher claims one pending row at a time and fences the claim with a lease token.
  • Transient publish failures leave the row pending so a later cycle can retry it.
  • A duplicate Kafka delivery finds the existing receipt and does not insert another one.
  • The local Docker demo uses one Kafka broker. That is not a highly available cluster, and it is not exactly-once delivery.

05 — Kafka Worker & Failure Handling

One receipt, then acknowledge. Poison goes to the dead-letter topic.

The worker parses the record, checks it against the persisted telemetry, and inserts a processing receipt before acknowledging the source.

  • A matching duplicate is absorbed when the receipt already exists.
  • A payload that does not match the stored reading, or that has no stored event, is poison and is not retried.
  • Poison records are published to the dead-letter topic. The source is acknowledged only after that send succeeds.
  • A failed dead-letter publication leaves the source unacknowledged, so the record is not skipped.

06 — Analytics & Data Processing

Aggregates come from accepted telemetry, not from receipts.

The API summarizes readings over a time window and keeps derived UTC hour statistics. Those statistics are rebuilt from telemetry_events.

  • Summary queries report counts and temperature, humidity, and battery aggregates for a device and window.
  • Hour buckets are derived data. A rebuild walks UTC days and commits each day separately.
  • A late occurredAt can change an earlier bucket, because the rebuild reads the accepted rows rather than a frozen receipt.
  • The rebuild is an explicit command. Its enabled flag defaults to off, so ordinary API startup does not recompute the tables.

07 — Interactive Pipeline Demo

The public page runs the pipeline in the browser.

The Vercel site is a TypeScript simulation of ingestion, a paused broker, duplicate delivery, poison records, and analytics. It does not call the Spring Boot API, and refreshing the page resets the model.

StreamForge browser simulation showing one accepted reading waiting at Kafka while the worker is running.
Pipeline view of the public simulation. The counters are the in-browser model, not measured throughput.
StreamForge simulation with the broker paused and a reading still pending publication.
Pausing the broker leaves the accepted reading pending. In the real stack, that pending row is the committed outbox record.
StreamForge simulation analytics view for accepted readings.
Analytics in the simulation follow accepted readings. They are not a production dashboard or a latency benchmark.

08 — Engineering Proof & Limitations

What the repository and the public page actually show.

The claims above come from the Java services, Flyway migrations, worker tests, and the live simulation. They are not a production deployment report.

  • Flyway migrations V1–V5 version the platform, ingestion, processed events, outbox claim and retry, and derived hour statistics.
  • API tests cover ingestion, rollback, outbox claim and publication, Kafka outage, and analytics queries and rebuilds.
  • Worker tests cover receipt insertion, duplicate delivery, poison isolation, and a dead-letter publish that fails closed.
  • GitHub Actions runs the Java backend, the frontend, and a disposable demo job. This page does not claim a green remote run or a test total.
  • The public URL was checked and serves the interactive simulation, which states that it is not a remote Kafka cluster.
  • No exactly-once Kafka delivery.
  • No hosted Kafka, PostgreSQL, or Spring Boot service behind the public URL.
  • No AWS, autoscaling, multi-region, or high-availability claim.
  • No measured throughput, latency, or SLA.
  • No production users, revenue, or OAuth and JWT product surface.