Skip to content

Bootstrap and recover feed state

Have your FeedHub instance name, assigned snapshot queue, matching resync exchange and queue, and subscribed sport IDs and phases to hand. Start after the first-delivery check exits. Use the existing broker objects from provisioning.

Flow Where to read and how to identify the reply
Catalog, membership and later betting requests Consume amq.rabbitmq.reply-to with automatic acknowledgement. Publish requests on that same channel, set AMQP reply-to to the pseudo-queue and set the JSON responseAddress to its endpoint URI. Match a reply by the JSON envelope requestId, expected concrete type and supported payload version. Use a fresh requestId per attempt, a finite deadline and the required AMQP user-id equal to your login.
Event resync Start a manual-ack consumer on the assigned fixed resync queue before catalog paging. Use the URI of its paired exchange for both JSON responseAddress and faultAddress. Follow a normal response by payload eventId and check freshness. For a typed fault, match the embedded original eventId, requestedAt and refFetchedAt to the pending attempt. Acknowledge each handled reply or fault on the receiving channel using its current delivery tag.

The transport reference gives the request properties, expiry and URI rules. The fixed reply reference shows how to address your resync replica.

  1. Leave the assigned snapshot queue collecting changes while you page the catalog. Read the five reference sets and store records by canonical ID. Follow page.nextCursor until it is absent or null. Keep each page query’s filters fixed. On later reads, retain the last applied reference watermark and expect records at that timestamp to reappear.
  2. Start a publication membership generation-only check before paging active events. In the ActiveEventPageRequest, set the JSON envelope header feedhub-publication-check-event-ids to "-" and use limit: 1 in the payload. Require a valid Ok reply and record the generation. An initially valid response with no generation indicates unmanaged publication. Once you have confirmed a managed generation, treat a reply with no generation as an unavailable membership check.
  3. Read active-event pages for each subscribed sport and phase. For example, use sportIds: ["01967fb0-0a00-7000-8000-000000000001"] and isLive: false for one prematch scope. Follow the cursor with the same filters, including after an empty page that still has a cursor. Each page.items[].event supplies an event snapshot and can include a manifest without market bodies.
  4. Check the generation again after the page pass. If it changed or a cursor was refused because the generation changed, discard the pass and restart at the first page. In a managed deployment, wait for a valid generation check before exposing the page set. On a generation change, check held and candidate event IDs in membership batches of up to 100 distinct IDs. Require every batch to confirm the same generation and each requested ID. Admit only visible candidates in the expected subscribed scope with a fetchedAt strictly after any applicable WithdrawnAt. Hide held events that membership confirms are hidden, moved or withdrawn. A missing or incomplete reply leaves eligibility unconfirmed.
  5. Apply the catalog event snapshots, allowing their manifests to trigger market repairs. Start the snapshot consumer with manual acknowledgement. Apply the backlog and subsequent deliveries with the same checks below. Resolve missing reference IDs with bounded by-ID lookups. Reference data model

Use canonical event and market IDs as state keys. Apply updates for each event atomically or serialize them. Track the last fetchedAt for the event and separately for each market, the last applicable manifest and any withdrawal cutoff. Compare parsed UTC timestamps. The phase, delivery order, AMQP delivery tag and producedAt serve different purposes from the entity version.

When you receive Apply this rule
Event or market snapshot Apply a newer version subject to subscription and withdrawal checks. Require an eligible event version newer than the withdrawal timestamp to restore an index-withdrawn event to active use. A terminal snapshot closes the event if it is newer than the held event version, even if it predates that withdrawal timestamp. An eligible full: true market snapshot can replace a non-withdrawn market at equal fetchedAt when its hash differs. A duplicate or stale delivery can be acknowledged once you have determined that it requires no effect.
Market with an unknown event ID Keep it out of active state. Allow a bounded wait for its event, then ask for ColdEvent resync if the event is still unknown. Use the event ID and leave the market IDs unset to request the entire event.
Event with a missing or null manifest Preserve the previous market membership information. This delivery makes no market-list assertion.
Event with a present manifest Treat it as the complete market list at the event’s fetchedAt. Withdraw omitted markets at or before that time. An empty array withdraws every eligible held market at or before that time. Keep that cutoff to block a late market snapshot with fetchedAt at or before it. Compare manifest hashes against missing markets and held market versions at or before the manifest’s fetchedAt.
Event index Use only its sport and phase. If the index omits a held active event whose fetchedAt is strictly before indexedAt, mark it withdrawn, suspend eligible markets at or before that horizon and ask for ColdEvent repair. An older index whose horizon is at or before a held event version leaves that event in place. In a current index, an unknown event or an entry newer than the held event version identifies a repair candidate.

For managed publication, require the authoritative flag and confirm the generation before applying an index. Check membership for held events omitted by that index. If it lists events you do not hold active, page that scope and confirm the generation again before applying those pages. Recheck held and candidate events when the generation changes. Restore hidden or withdrawn state only with eligible data from the current generation. Apply ordinary unmarked indexes only while publication is unmanaged.

Commit state before acknowledging the delivery tag on the channel that received it. Use a configured failure policy to preserve malformed or unsupported input for investigation. Feed freshness rules · Event model · Market model

This worked example uses synthetic canonical IDs and UTC timestamps. Suppose you hold a market snapshot at 2026-11-30T09:59:58Z with hash a81c54ea3653d702. An event snapshot at 2026-11-30T10:00:00Z lists that market with expected hash b4d117e9a02c734e. The market ID is outside changedMarketIds, and you have caught up with the queue.

  1. Publish an event resync request to feedhub-resync-<instance> with routing key "". Set both reply addresses to the assigned fixed resync exchange. Request only the mismatched market. For a market listed in changedMarketIds, first allow the expected snapshot to arrive, then reassess whether repair is still needed.

    The example EventResyncRequest payload goes under message in the wire envelope.

    {
    "schemaVersion": 1,
    "messageId": "01967fb0-0a00-7000-8000-000000000211",
    "producedAt": "2026-11-30T10:00:05Z",
    "eventId": "01967fb0-0a00-7000-8000-000000000002",
    "reason": "HashMismatch",
    "requestedAt": "2026-11-30T10:00:05Z",
    "marketIds": ["01967fb0-0a00-7000-8000-000000000003"],
    "refFetchedAt": "2026-11-30T10:00:00Z"
    }
  2. Read the response on the fixed queue. For Served, check the scope and eligibility, apply the event before the returned full: true market snapshot, and keep the newer held state if any. A market snapshot at 2026-11-30T10:00:00Z with the expected hash repairs the example mismatch. It can also replace a non-withdrawn copy with a different hash at that same timestamp. A later-arriving snapshot at 09:59:58Z leaves the repair in place.

  3. Keep one in-flight repair per event. Use a finite local deadline, delay hash-driven requests while catching up, and bound retries with backoff. Recheck the current gap before retrying. An Unknown, Failed or unsupported outcome leaves held state in place. Recheck membership for a managed hidden reply. Apply a usable late reply with the ordinary version checks, then acknowledge that delivery on its receiving channel.

  1. Reconnect to the same assigned queues with backoff. Recreate the fixed resync and snapshot consumers, the Direct Reply-To channel and its consumer, and the results consumer if you use betting. Direct Reply-To replies are transient. Treat outstanding calls on the lost channel as unanswered and follow each operation’s retry rules.
  2. Keep durable event and market versions across the disconnect. Queue length limits can drop older snapshots and TTL can expire deliveries from the backlog. Continue applying queued deliveries and look for gaps using current indexes, managed membership and manifest hashes. Apply repairs one event at a time. Redeliveries and late resync replies use the same freshness checks as live updates.
  3. Read the catalog again if the store was lost or available indexes cannot cover the gap, for example after an extended outage or with indexes disabled. Repeat scoped paging and, for managed publication, confirm generation and membership before reconciling. Compare the complete page pass for the affected scopes against held state. Use membership or a ColdEvent repair to resolve a held event missing from the pages. Use manifest comparisons to find markets that still need repair.

For a betting-enabled sandbox identity, continue with Betting and settlement.