Skip to main content

Domain events

Every event this context consumes, from apis/asyncapi.yaml and the consumers in internal/adapters/inbound/kafka. The context publishes nothing: no retailnetwork.product-discovery.events topic is ever written and no analytics topic exists. The summary table with guards is on the event catalogue; this page adds the envelope, the ordering rules and the failure semantics.

Envelope​

Every consumed Kafka message is a CloudEvents 1.0 event in structured JSON mode, minted by its producer. internal/adapters/kafka/cloudevents.Decode accepts nothing else (the retired flat envelope is refused and the message is skipped).

AttributeValue (per producer)
specversion1.0
ida UUID minted once by the producer; a redelivery carries the same id, the inbox key
source/retailnetwork/offer-availability, /retailnetwork/product-content or /retailnetwork/pricing
typecom.retailnetwork.<tier>.<producer>.<entity>.<EventName>: tier commerce for offer-availability, storefront for the two siblings
subjectthe producer's root id; the Kafka key is the item id (item, content, price) or the listing id (listing)
timethe instant the fact happened
datacontenttypeapplication/json
dataschemaurn:retailnetwork:<producer>:events:<EventName>:v1

Source: internal/adapters/kafka/cloudevents/cloudevents.go, apis/asyncapi.yaml.

Consumption rules​

  • Idempotent on the id: the id is inserted into processed_events in the same transaction as the fold; a repeat is acknowledged without effect.
  • Dispatch on the full type string, never on a suffix; unknown types are skipped, committed and counted in discovery.kafka.poison_messages (reason=unknown-type).
  • Ordering: within one producer, events with the same key arrive in order. Across keys and producers nothing is promised, so the per-source guards sit on top of the inbox: listing asOf, content revision, price version, tree version. A fact for an item whose CatalogItemCreated has not landed creates an invisible stub that the create completes.
  • Tolerant reader: only the fields below are read; others are ignored.
  • Failure: an undecodable payload or an unusable value is dead-lettered at once to <topic>.dlq; a transient failure is retried up to 5 times, then dead-lettered.

Published​

None. A read side with no events out keeps every write path free of a dependency on this context. The cost is that search analytics (query terms, zero-result and fallback rates) have no event to ride on; the discovery.searches.served counter is the only signal.

Consumed from offer-availability​

Topic retailnetwork.offer-availability.events, group OFFER_AVAILABILITY_CONSUMER_GROUP.

Eventdata fields readWhat the context does
CatalogItemCreatedcatalogItemId, title, hazmat, fragileCreates or completes the row: title and flags, item ACTIVE. Dimensions, weight and GTIN are not read
CatalogItemDiscontinuedcatalogItemIdItem DISCONTINUED: purchasable goes false. The row stays, rendered as currently unavailable
ListingCreatedlistingId, catalogItemId, nodeIdLearns the listing to item mapping; adds a LIVE listing with no quantity
ListingAvailabilityChangedlistingId, catalogItemId, nodeId, availableQty, asOfSets the quantity under the asOf guard; recomputes inStock and purchasable. basis, feedId and ownerRef are not read
ListingSuppressedlistingIdListing SUPPRESSED; never counts towards inStock. The item comes from the stored mapping. The network's reason is not read
ListingRestoredlistingIdListing LIVE again

Consumed from product-content​

Topic retailnetwork.product-content.events, group PRODUCT_CONTENT_CONSUMER_GROUP.

Eventdata fields readWhat the context does
ProductContentPublishedcatalogItemId, revision, description, bullets, attributes, media, primaryCategoryIdReplaces the content and the category id under the revision guard; re-indexes the search document; content PUBLISHED
ProductContentRetiredcatalogItemId, revision (optional)Content RETIRED: the row stops being searchable and purchasable
CategoryTreePublishedversion, categories[{categoryId, parentId, name, path}]Replaces the whole tree under the version guard; purchasable counts are re-derived. No product row is re-indexed

Consumed from pricing​

Topic retailnetwork.pricing.events, group PRICING_CONSUMER_GROUP.

Eventdata fields readWhat the context does
ItemPriceChangedcatalogItemId, currency, listPriceMinor, effectivePriceMinor, versionSets both prices under the version guard; price ACTIVE
ItemPriceWithdrawncatalogItemId, versionPrice WITHDRAWN, amounts cleared; a withdrawal at a newer version is recorded even when already withdrawn

Example envelope​

The event the purchasable verdict turns on, ListingAvailabilityChanged, one listing dropping to zero (ids synthetic, values illustrative):

{
"specversion": "1.0",
"id": "9a1c7b52-3d84-4f0e-8b7a-2c5d9e0f1a3b",
"source": "/retailnetwork/offer-availability",
"type": "com.retailnetwork.commerce.offer-availability.listing.ListingAvailabilityChanged",
"subject": "LST-40987",
"time": "2026-10-25T09:41:07Z",
"datacontenttype": "application/json",
"dataschema": "urn:retailnetwork:offer-availability:events:ListingAvailabilityChanged:v1",
"data": {
"listingId": "LST-40987",
"catalogItemId": "CI-100234",
"nodeId": "NODE-MSP-14",
"availableQty": 0,
"asOf": "2026-10-25T09:41:05Z"
}
}

The context reads five fields of data, inserts the id into processed_events, applies the asOf guard and, if the item's last live listing just went to zero, flips inStock and purchasable to false in the same transaction. No personal data travels in any of these events.

Source: internal/adapters/inbound/kafka/offer_availability.go, internal/domain/productview/fold_listing.go.