Skip to main content

Integration

This context calls no other service at runtime. It talks to its neighbours only through Kafka: it consumes three producers' topics into local read models and publishes two topics of its own. Everything else here is how others read it.

DirectionPeerProtocolContract
Upstreamnode-topologyKafka, topic retailnetwork.node-topology.events7 event types
Upstreamorder-sourcingKafka, topic retailnetwork.order-sourcing.events4 event types
Upstreamshipping-and-trackingKafka, topic retailnetwork.shipping-and-tracking.events2 event types
Downstreamorder-sourcing, delivery-promiseKafka, topic retailnetwork.linehaul-transportation.eventsdeparture and booking events
Downstreamshipping-and-tracking, last-mile-deliveryKafka, same topicLoadDeparted, LoadArrived
Downstreamanalytics readersKafka, topic retailnetwork.linehaul-transportation.analyticsDepartureDeparted, DepartureArrived, LoadClosed
Clientsplanners, operators, UIsREST on cmd/api (Kong /api/linehaul-transportation)apis/openapi.yaml
ClientsAI agentsMCP on cmd/mcp (Kong /api/mcp/linehaul-transportation)list_departures, get_departure
Clientspeer agentsA2A on cmd/a2a (Kong /api/a2a/linehaul-transportation)skills list_departures, get_departure

All Kafka messages are CloudEvents 1.0 in structured mode (content-type: application/cloudevents+json; charset=UTF-8); the CloudEvents id is the dedupe key, the subject and Kafka key are the aggregate id, and type is com.retailnetwork.<tier>.<context>.<entity>.<EventName>. REST, MCP and A2A are unauthenticated; the cluster network boundary is the access control.

Upstream: consumed events​

Source: internal/adapters/inbound/kafka/handlers.go, consumer.go; contract copies in apis/asyncapi.yaml (*Received messages), ADR 0003.

ProducerEvent type (CloudEvents type)Fields relied onEffect
node-topologycom.retailnetwork.logistics.node-topology.node.NodeRegisterednodeId, nodeType, operator, timezoneCreates the node view
node-topology...node.NodeOperationalProfileDeclarednodeId, profileRevision, timezone, operatingHoursByDay, holidays, cutoffs[], throughputCapStores the profile, re-plans pickups
node-topology...node.NodeActivated, NodeSuspended, NodeRetirednodeIdPickups generated or cancelled
node-topology...lane.LaneOpenedlaneId, originNodeId, destinationNodeId, mode (GROUND or AIR), nominalTransitMinutesCreates or refreshes the lane view
node-topology...lane.LaneClosedlaneIdLane closed: no new departures
order-sourcingcom.retailnetwork.commerce.order-sourcing.assignment.FulfillmentReleasedToNodeassignmentId, releaseNo, orderId, groupNo, nodeId, pickupDepartureIdRecords the expected volume
order-sourcing...assignment.FulfillmentReassignedassignmentId, toNodeIdUpdates the node
order-sourcing...assignment.FulfillmentLockedassignmentId, orderId, groupNo, nodeId, pickupDepartureId, optional consolidatedIntoBooks capacity (BookOnLock); a lock with consolidatedInto (a follower of a merged package) books nothing, the carrier's lock books the one package (ADR 0014)
order-sourcing...assignment.FulfillmentCancelledassignmentIdMarks the volume cancelled
shipping-and-trackingcom.retailnetwork.logistics.shipping-and-tracking.label.LabelIssuedassignmentId, trackingNumberAdds the tracking number
shipping-and-tracking...label.LabelVoidedtrackingNumberRemoves it

Consumer groups are mandatory settings (NODE_TOPOLOGY_CONSUMER_GROUP, ORDER_SOURCING_CONSUMER_GROUP, SHIPPING_AND_TRACKING_CONSUMER_GROUP). Payload decoding is tolerant: only the fields above are read and unknown fields and unknown event types are ignored.

Failure behaviour. Each message is claimed in processed_events(consumer, event_id) in the same transaction as its effect, so redelivery is harmless. A message that is not a valid CloudEvent, or whose data can never be applied (undecodable, refused by the domain), is dead-lettered to <topic>.dlq with x-dlq-* headers and the offset is committed. A transient handler failure is retried on the same message with a 200 ms to 5 s backoff and dead-lettered after 5 attempts. A stalled or reset broker connection is retried (up to 10 consecutive failures); a refused connection ends the worker and the process, and Kubernetes restarts it. An event that arrives before what it depends on (a lane before its nodes, a lock before its release) is applied in whatever order it comes: the views are order-tolerant, and pickups are re-planned when the missing piece arrives (Use cases). A topic that has not been written yet is simply empty.

Downstream: published events​

Source: internal/adapters/kafka/wire/wire.go, apis/asyncapi.yaml. The full catalogue with fields is on Events.

TopicEvents
retailnetwork.linehaul-transportation.eventsDepartureScheduled, DepartureCapacityChanged, DepartureCancelled, BookingMoved, BookingFailed, LoadDeparted, LoadArrived
retailnetwork.linehaul-transportation.analyticsDepartureDeparted, DepartureArrived, LoadClosed

Delivery is at-least-once with a stable event id (ADR 0005); events of one aggregate are keyed by it, so they stay ordered per partition unless a row reaches the attempt cap and is overtaken (Runbook). Consumers must dedupe on id, dispatch on the full type and ignore unknown types.

Consumers found in sibling repositories on develop (read from their code, not from this service):

ConsumerTypes it handles from this serviceUse
delivery-promiseDepartureScheduled, DepartureCapacityChanged, DepartureCancelled, BookingMoved, BookingFailed, LoadDeparted, LoadArrivedBuilds its departures read model; revises promises on a cancellation and flags a promise AT_RISK on a moved or failed booking; pairs the load events into measured transit
order-sourcingDepartureScheduled, DepartureCapacityChanged, DepartureCancelled, BookingMoved; BookingFailed is received but changes no statePickup availability, rebooked assignments
shipping-and-trackingLoadDeparted, LoadArrivedPackage timeline (pickup departure, station arrival)
last-mile-deliveryLoadArrivedInducts packages into delivery waves when the destination is a delivery station

If one of them is down, nothing happens here: the relay publishes regardless and the consumer catches up from its committed offsets.

Absent edges​

  • No outbound REST, MCP or A2A call to any context. The three agent and REST adapters only read this context's own database.
  • No call to vendor-connectivity and no knowledge of vendors beyond node-topology's profile. The warehouse-systems fleet reaches the network only through the Vendor API; this context never talks to it.
  • No dependency on warehouse-console at runtime. The linehaul_mfe remote (web/, ADR 0009) is a read-only screen served by the web gateway that calls this context's REST through Kong.
  • No schema registry. Contracts are apis/asyncapi.yaml and a fitness test (TestEventCatalogueMatchesContract) that keeps the code in line with it.

Reading the service​

InterfaceWhereNotes
RESTcmd/api :8080, Kong /api/linehaul-transportationEleven resource paths plus /healthz and /readyz; errors are RFC 9457 problems; every POST needs Idempotency-Key
MCPcmd/mcp :8090, /mcp; Kong /api/mcp/linehaul-transportation (opt-in)Read-only tools, see MCP tools
A2Acmd/a2a :8093, / and /a2a; Agent Card /.well-known/agent-card.json; Kong /api/a2a/linehaul-transportation (opt-in)Read-only skills; A2A carries delegation only, facts between contexts travel as CloudEvents

See API overview for the endpoint table.