Event catalogue
Every Kafka message this service produces or consumes is a CloudEvents 1.0
event in structured mode: the Kafka value is the whole JSON envelope and the
header content-type is application/cloudevents+json; charset=UTF-8.
Envelopes are built only in internal/adapters/kafka/cloudevents and encoded
in internal/adapters/outbound/kafka/encoder.go
(ADR 0004). The
contract is apis/asyncapi.yaml (AsyncAPI 3.0.0); field-level detail is on
Domain events.
:::info Built
The outbox relay and the three consumers run inside cmd/api and are always
on: the process refuses to boot without DATABASE_URL, KAFKA_BROKERS,
DELIVERY_PROMISE_URL and the three consumer group ids
(Configuration). The tables below are the
pinned contract, not observed traffic. Which sibling reads or writes the other
side of each edge is on Integration.
:::
Read back for analytics
The optional analytics projector (cmd/co-projector, ADR 0018) reads this context's OWN topic back in the group customer-ordering-analytics and projects all three published types into a separate analytical database: ids, codes, counts and instants only (no address, postal prefix, shopper, consolidation key, cancellation reason or pickup point id). It reads no sibling's topic and publishes nothing; poison goes to retailnetwork.customer-ordering.analytics.dlq.
Published
Topic retailnetwork.customer-ordering.events, source
/retailnetwork/customer-ordering, dataschema
urn:retailnetwork:customer-ordering:events:<EventName>:v1. The Kafka key and
the CloudEvents subject are the orderId, so one order's events stay on one
partition and in order. The id is minted once, when the event is written to
outbox_events, and a relay retry repeats it.
| Type | Raised when | data |
|---|---|---|
com.retailnetwork.commerce.customer-ordering.customerorder.CustomerOrderPlaced | PlaceOrder saved the order in state PLACED | orderId, shopperId, destinationPostalPrefix, placedAt, consolidationKey?, groups[{groupNo, promiseId, tier, witnessNodeId, shipBy, deliverByEarliest, deliverByLatest, timeZone?, chosenDeliveryDay?, consolidationEligible?, lines[{lineNo, catalogItemId, quantity}]}] |
com.retailnetwork.commerce.customer-ordering.customerorder.CustomerOrderCancelled | the shopper cancelled (CancelOrder) or the CancelOnUnfulfillable policy cancelled a group (PromiseUnkeepable) | orderId, reason, cancelledAt, groupNos[] |
tier is SAME_DAY, NEXT_DAY, TWO_DAY, STANDARD or CONSOLIDATED (the
real tier of the promise; ADR 0013).
chosenDeliveryDay and consolidationEligible exist on CONSOLIDATED groups
only, are optional and additive on v1, and an absent consolidationEligible is
unknown, never false; a consumer must accept the fifth tier before any shopper
can choose it. timeZone is the
IANA zone of the destination, optional and additive on v1
(ADR 0009); it is omitted when
unknown. consolidationKey is the opaque keyed hash of shopper and ship-to that
lets order-sourcing merge the groups of one shopper and one address
(ADR 0012); it is
optional and additive on v1, omitted when the service has no secret, and an absent
key means the order never merges. No event carries the ship-to address. A cancellation is a request:
order-sourcing answers with FulfillmentCancelled or FulfillmentCancelRefused.
Nothing is published on retailnetwork.customer-ordering.analytics.
Consumed
Dispatch is on the full type; unknown types on a topic are ignored. Every
handler claims the CloudEvents id in processed_events in the same
transaction as its effect, so an event is applied at most once.
| Topic (consumer group variable) | Type | Effect (handler in usecases.Consumer) |
|---|---|---|
retailnetwork.delivery-promise.events (DELIVERY_PROMISE_CONSUMER_GROUP) | com.retailnetwork.commerce.delivery-promise.promise.PromiseAtRisk | records the at-risk reason (ApplyPromiseAtRisk) |
| same | ...promise.PromiseRevised | new window, ship-by, node, zone; stale revisionNo ignored (ApplyPromiseRevised) |
| same | ...promise.PromiseKept, ...promise.PromiseBroken | records the verdict and lateByMinutes |
| same | ...promise.PromiseUnkeepable | policy CancelOnUnfulfillable: the group becomes CANCELLED and CustomerOrderCancelled is raised |
retailnetwork.order-sourcing.events (ORDER_SOURCING_CONSUMER_GROUP) | com.retailnetwork.commerce.order-sourcing.assignment.FulfillmentLocked | group LOCKED, order IN_FULFILLMENT |
| same | ...assignment.FulfillmentShipped | tracking numbers stored, group SHIPPED |
| same | ...assignment.FulfillmentUnsourceable | reason recorded in the tracking view |
| same | ...assignment.FulfillmentCancelled | group CANCELLED |
| same | ...assignment.FulfillmentCancelRefused | group back to LOCKED, refusal reason kept |
retailnetwork.shipping-and-tracking.events (SHIPPING_CONSUMER_GROUP) | com.retailnetwork.logistics.shipping-and-tracking.label.LabelIssued, ...label.LabelVoided | package created or completed / voided |
| same | ...journey.PackageScanned, ...journey.PackageExceptionRaised | newest scan / exception reason |
| same | ...journey.PackageDelivered | package delivered; every group that named the tracking number (several, once order-sourcing merges groups into one package, ADR 0012) becomes DELIVERED when all its packages are |
| same | ...journey.PackageLost, ...journey.PackageReturned | every group that named the tracking number becomes LOST / RETURNED (terminal) |
| same | ...journey.PackageEtaWindowAssigned | the package's day-of delivery window (etaStart, etaEnd, latest assignedAt wins) is stored; the tracking view shows it only while the package is OUT_FOR_DELIVERY and the window is not older than the last scan (ADR 0014). The group promise is untouched |
| same | ...journey.PackageDeliveryPointFlagged | the delivery-point advisory (reason NOT_HOME or ACCESS_PROBLEM, flaggedAt, newest wins) is stored on the package row; the tracking view carries it until the package ends - DELIVERED, RETURNED, LOST or VOIDED (ADR 0015). Codes only; the shopper wording is the storefront's |
| same | ...journey.PackageReadyForCollection | a pickup package reached its point: readyForCollectionAt and holdUntil are stored on the package row and the tracking view shows them (ADR 0016). No aggregate changes |
| same | ...journey.PackageCollected | the shopper collected the package: collectedAt and the optional proofCode are stored on the package row (ADR 0016). No aggregate changes |
Twenty-one types are consumed (five from delivery-promise, five from
order-sourcing, eleven from shipping-and-tracking), one Consumer.Apply* handler
each; the code (internal/adapters/inbound/kafka/handlers.go), the channel and
operation lists and the prose in apis/asyncapi.yaml all say twenty-one. The
messages list only the fields this service relies on; unknown fields are ignored
(tolerant reader).
Only these three topics are consumed. In particular this service does not
consume TransferAllocationReleaseRequested (ADR 0051 of inventory-storage):
that command is published by network-inventory-planning and consumed by
inventory-storage, and no string of it appears in this repository's code or
contracts.
A failed handler is retried (capped backoff, 5 attempts) and then the message
goes to <topic>.dlq with x-dlq-* headers; a payload that can never be
applied goes there at once
(internal/adapters/inbound/kafka/deadletter.go). See the
Runbook.