Skip to main content

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 and decoded only in internal/adapters/kafka/cloudevents (ADR 0004). The contract is apis/asyncapi.yaml (AsyncAPI 3.0.0, version 1.0.0); the same events with their producing command are on Domain events, and the topology of the edges is on Integration.

Envelope​

AttributeValue
specversion1.0
ida UUID minted once by the encoder and stored with the outbox row, so a relay retry republishes the same id
source/retailnetwork/order-sourcing
typecom.retailnetwork.commerce.order-sourcing.assignment.<EventName> (tier commerce, entity assignment for every event)
subject and Kafka keythe assignmentId, so one assignment's events stay in order on one partition
timethe instant of the transition, UTC
datacontenttypeapplication/json
dataschemaurn:retailnetwork:order-sourcing:<events|analytics>:<EventName>:v1

Source: internal/adapters/kafka/cloudevents/cloudevents.go (New, Type, DataSchema), internal/adapters/outbound/kafka/encoder.go (Encoder.Encode). data is camelCase JSON, timestamps are RFC 3339 UTC, arrays are always present. A breaking payload change would be a new .v2 type; every schema version today is 1.

Published​

Fifteen events, written through the transactional outbox in the same transaction as the aggregate and drained by the always-on relay in cmd/api (at least once). Nine go to retailnetwork.order-sourcing.events; the six analytics-only events go only to retailnetwork.order-sourcing.analytics. FulfillmentSourcingDecided is written in the same transaction as every FulfillmentReleasedToNode, with its own id (ADR 0013); its optional fields are omitted when unknown (inRegion when either region is unknown, estimatedCostCents when the estimate is incomplete, so costComplete is false).

FulfillmentReleasedToNode and FulfillmentSourcingDecided also carry two optional policy fields (ADR 0014): policyVersion, the sourcing policy version the search read (omitted when no version was published), and effectiveCostCents, the estimate plus the cross-region surcharge (omitted unless a surcharge changed the cost; present even when the estimate is incomplete). Consumers (vendor-connectivity, delivery-promise) decode them tolerantly. SourcingPolicyPublished is the one event of the policy entity: its type is com.retailnetwork.commerce.order-sourcing.policy.SourcingPolicyPublished, its subject and Kafka key are the constant policy, and it is raised by PUT /sourcing-policy.

A release may be MERGED (ADR 0015): the carrier's FulfillmentReleasedToNode then lists members[{assignmentId, orderId, groupNo, promiseId}] and the union of the lines (each with its own optional assignmentId), and every member raises its own FulfillmentLocked (a follower also carries consolidatedInto, every member mergedAssignmentIds), FulfillmentShipped and FulfillmentDelivered. FulfillmentReleaseWithdrawn takes a published merged release back when a promise revision dissolves it; AssignmentsConsolidated and AssignmentsDeconsolidated are analytics only. Every merge field is optional and omitted when the release is not merged.

Event (type suffix after assignment.)TopicRaised bydata
FulfillmentQueuedanalyticsQueueAssignmentassignmentId, orderId, groupNo, promiseId, deliverByLatest, lines[{lineNo, catalogItemId, quantity}]
FulfillmentReleasedToNodeeventsReleaseToNode, QueueAssignment (SAME_DAY)assignmentId, releaseNo, orderId, groupNo, nodeId, pickupDepartureId, requiredShipBy, promisedDeliverByLatest, tier, lines[{catalogItemId, listingId, ownerRef (optional), quantity, assignmentId (optional)}], estimatedCostCents (optional), policyVersion (optional), effectiveCostCents (optional), members (optional, merged release only)
FulfillmentSourcingDecidedanalyticswith every FulfillmentReleasedToNodeassignmentId, orderId, groupNo (optional), releaseNo, nodeId, nodeRegionId (optional), destinationRegionId (optional), inRegion (optional), legs, estimatedCostCents (optional), costComplete, units, candidateCount, decidedAt, policyVersion (optional), effectiveCostCents (optional), carrierAssignmentId (optional), consolidatedCount (optional)
FulfillmentReassignedeventsReoptimiseAssignment, ReleaseToNode, HandleNodeRefusal, ApplyRevisedPromise (node changed)assignmentId, fromNodeId, toNodeId, reason, assignmentVersion
FulfillmentLockedeventsLockAssignment (every member of a merged release)assignmentId, orderId, groupNo, promiseId, nodeId, pickupDepartureId, lockedAt, lockReason, consolidatedInto (optional), mergedAssignmentIds (optional)
FulfillmentShippedeventsMarkShippedassignmentId, orderId, groupNo, nodeId, trackingNumbers, shippedAt
FulfillmentDeliveredanalyticsMarkDelivered (last package)assignmentId, orderId, groupNo, deliveredAt
FulfillmentUnsourceableeventsQueueAssignment, ReoptimiseAssignment, ReleaseToNode, HandleNodeRefusal, ApplyRevisedPromiseassignmentId, orderId, groupNo, promiseId, excludedNodes[{nodeId, reason}], reason
FulfillmentCancelledeventsCancelAssignmentassignmentId, orderId, groupNo, reason
FulfillmentCancelRefusedeventsCancelAssignment (after the lock, or while a merged release is not yet locked)assignmentId, orderId, groupNo, reason (CANCEL_AFTER_LOCK or CANCEL_WHILE_MERGED)
FulfillmentConstraintRevisedeventsApplyRevisedPromiseassignmentId, revisionNo, deliverByLatest
SourcingPolicyPublished (type ...order-sourcing.policy.SourcingPolicyPublished, subject policy)analyticsSourcingPolicies.Publish (PUT /sourcing-policy)version, crossRegionSurchargeCents, maxCostDeviationPercent, consolidationMaxAssignments, publishedAt
FulfillmentReleaseWithdrawneventsApplyRevisedPromise (a revision breaks the merged window)assignmentId, releaseNo, orderId, groupNo, reason (PROMISE_REVISED), withdrawnAt
AssignmentsConsolidatedanalyticsReleaseToNode (a merged release)carrierAssignmentId, releaseNo, nodeId, memberCount, units, members[{assignmentId, orderId, groupNo, promiseId, units}], consolidatedAt
AssignmentsDeconsolidatedanalyticsHandleNodeRefusal, ApplyRevisedPromisecarrierAssignmentId, releaseNo, reason, triggerAssignmentId (optional), memberAssignmentIds, deconsolidatedAt

Reason vocabularies in the code (internal/domain/assignment/types.go): FulfillmentReassigned.reason is REOPTIMISED, RELEASE_RECHECK, PURCHASE_ORDER_REJECTED, PURCHASE_ORDER_EXPIRED, PROMISE_REVISED or CONSOLIDATION_WITHDRAWN; FulfillmentUnsourceable.reason is NO_CANDIDATE or NODE_REFUSED; FulfillmentLocked.lockReason is PURCHASE_ORDER_ACCEPTED. Each excluded node's reason is REJECTED, REJECTED:<reasonCode> or EXPIRED.

Consumed​

Nine topics, 34 event types, each under its own consumer group read from the environment (<PRODUCER>_CONSUMER_GROUP, see Configuration). Dispatch is on the full type; every other type on those topics is ignored. The Effect column names the use case; the rest feed the five local read models.

Topictype (after com.retailnetwork.)Effect
retailnetwork.customer-ordering.eventscommerce.customer-ordering.customerorder.CustomerOrderPlacedQueueAssignment
commerce.customer-ordering.customerorder.CustomerOrderCancelledCancelAssignment
retailnetwork.delivery-promise.eventscommerce.delivery-promise.promise.PromiseRevisedApplyRevisedPromise
commerce.delivery-promise.promisebook.PromiseBookExhaustedbook pressure (rm_book_pressure)
retailnetwork.vendor-connectivity.eventspartner.vendor-connectivity.purchaseorder.PurchaseOrderAcceptedLockAssignment
partner.vendor-connectivity.purchaseorder.PurchaseOrderRejectedHandleNodeRefusal (REJECTED)
partner.vendor-connectivity.purchaseorder.PurchaseOrderExpiredHandleNodeRefusal (EXPIRED)
partner.vendor-connectivity.purchaseorder.VendorShipmentConfirmedMarkShipped
retailnetwork.shipping-and-tracking.eventslogistics.shipping-and-tracking.journey.PackageDeliveredMarkDelivered
retailnetwork.linehaul-transportation.eventslogistics.linehaul-transportation.departure.BookingMovedRecordPickupMoved
logistics.linehaul-transportation.departure.BookingFailedRecordProcessed (inbox only)
logistics.linehaul-transportation.departure.DepartureScheduled, DepartureCapacityChanged, DepartureCancelleddepartures (rm_departures)
retailnetwork.last-mile-delivery.eventslogistics.last-mile-delivery.wave.DeliveryWaveScheduled, DeliveryWaveCapacityChanged, DeliveryWaveCancelled, WaveCostDeclaredwaves (rm_waves)
retailnetwork.node-topology.eventslogistics.node-topology.node.NodeRegistered, NodeOperationalProfileDeclared, NodeActivated, NodeSuspended, NodeRetirednodes (rm_nodes)
logistics.node-topology.lane.LaneOpened, LaneClosed, LaneCostDeclaredlanes (rm_lanes)
logistics.node-topology.servicearea.ServiceAreaAssignedservice areas (rm_service_areas)
logistics.node-topology.region.RegionDefinedregions (rm_regions)
retailnetwork.offer-availability.eventscommerce.offer-availability.listing.ListingCreated, ListingAvailabilityChanged, ListingSuppressed, ListingRestoredlistings (rm_listings)
commerce.offer-availability.catalogitem.CatalogItemDiscontinuedrm_discontinued_items
retailnetwork.node-performance.eventspartner.node-performance.scorecard.NodeScorecardUpdatedscorecards (rm_scorecards)

Source: internal/adapters/inbound/kafka/handlers.go (Handlers.Topics and one method per topic).

Fields read from each consumed event​

Eventdata fields used
CustomerOrderPlacedorderId, destinationPostalPrefix, groups[{groupNo, promiseId, tier, witnessNodeId, deliverByLatest, lines[{lineNo, catalogItemId, quantity}]}]
CustomerOrderCancelledorderId, groupNos, reason
PromiseRevisedpromiseId, revisionNo, deliverByLatest, nodeId (the new witness)
PromiseBookExhaustedbookId, nodeId, pickupDepartureId
PurchaseOrderAcceptedassignmentId, releaseNo, acceptedAt
PurchaseOrderRejected, PurchaseOrderExpiredassignmentId, releaseNo, reasonCode (rejected only, trimmed)
VendorShipmentConfirmedassignmentId, trackingNumbers, shippedAt
PackageDeliveredassignmentId, trackingNumber, deliveredAt
BookingMovedassignmentId, fromDepartureId, toDepartureId
BookingFailedassignmentId (only recorded as processed)
DepartureScheduleddepartureId, laneId, kind, originNodeId, destinationNodeId, cutoffAt, departsAt, arrivesAt, capacityPackages
DepartureCapacityChangeddepartureId, remainingPackages
DepartureCancelleddepartureId
DeliveryWaveScheduledwaveId, stationNodeId, inductCutoffAt, windowStart, windowEnd, stopCapacity
DeliveryWaveCapacityChangedwaveId, remainingStops
DeliveryWaveCancelledwaveId
WaveCostDeclaredwaveId, costPerStopCents, declaredAt
NodeRegisterednodeId, nodeType, subtype, operator, regionId
NodeOperationalProfileDeclarednodeId, profileRevision, handlingTimeMinutes
NodeActivated, NodeSuspended, NodeRetirednodeId and activatedAt / suspendedAt / retiredAt (falls back to the event time)
LaneOpenedlaneId, originNodeId, destinationNodeId, mode
LaneClosedlaneId
LaneCostDeclaredlaneId, costPerUnitCents, declaredAt
ServiceAreaAssignedpostalPrefix, deliveryStationNodeId, regionId, assignmentVersion
RegionDefinedregionId, code, name
ListingCreatedlistingId, catalogItemId, nodeId
ListingAvailabilityChangedlistingId, catalogItemId, nodeId, availableQty, asOf
ListingSuppressed, ListingRestoredlistingId
CatalogItemDiscontinuedcatalogItemId
NodeScorecardUpdatednodeId, window, grade, computedAt

Delivery guarantees​

  • Publishing is at least once through the outbox; the CloudEvents id is stable across retries, so consumers dedupe on it. The relay stops retrying a row after OUTBOX_MAX_ATTEMPTS and leaves it for an operator (Runbook).
  • Consuming is idempotent on the CloudEvents id through processed_events, written in the same transaction as the change. Failures retry with backoff; a payload that can never be applied is published to <topic>.dlq (Runbook). A message that is not a valid CloudEvents 1.0 event, including the retired flat envelope, is logged and skipped.
  • Ordering per assignment holds on the produced topics because the Kafka key is the assignmentId. Consumed topics are read per partition; the read-model upserts converge in any arrival order (newer revision or instant wins).
  • Topics are never created by this service through an admin API; the broker auto-creates each on first write.