Skip to content

Place a sandbox bet and process its settlement

Use a betting-enabled sandbox client, its provisioned results queue and an available sandbox fixture. The examples use synthetic IDs, prices and times. Substitute your fixture and the current request time when running the exercise.

  1. Use Direct Reply-To on the same AMQP channel for catalog, refresh, placement and status publishes and their replies. Start the automatic-ack reply consumer first. Stamp the AMQP user-id with the authenticated username. Match replies on their envelope requestId and concrete type, then validate the payload schema.

  2. Publish a pre-bet markets refresh to feedhub-refresh-<instance> with the chosen market ID. In an Ok reply, require a Served event with a usable snapshot of that exact market and the chosen selectionId. Confirm current publication eligibility in a managed deployment. Apply the event and markets with the usual freshness checks. Place only if the selection is still available and unsuspended at the expected price in the resulting state. Bet model

  3. Generate a clientBetKey and persist it with the original order under your FeedHub client identity before publishing. Place the order using urn:message:FeedHub.Contracts:BetPlacementRequest on feedhub-bets-<instance> with routing key "". Put the payload below in the envelope’s message. Give the request a distinct envelope requestId. Use a short queue expiry and a local response deadline long enough for processing. The reference illustrates a three-second queue expiry and fifteen-second local response deadline. Observe publisher confirms and returns from mandatory publishing. A broker confirm reports the broker’s handling of the publish. FeedHub confirms acceptance through the business reply. Placement request and outcomes

    {
    "schemaVersion": 1,
    "clientBetKey": "sample-ticket-001",
    "marketId": "01967fb0-0a00-7000-8000-000000000003",
    "selectionId": "01967fb0-0a00-7000-8000-000000000006",
    "price": "1.85",
    "stake": "2.00",
    "acceptPriceChanges": false,
    "isLive": false,
    "requestedAt": "2026-11-30T10:03:00Z"
    }
  4. On the matching BetPlacementReply, require outcome: "Accepted", the echoed clientBetKey and a valid FeedHub betId to record acceptance. Persist the association. In this example the accepted bet ID is 01967fb0-0a00-7000-8000-000000000311.

A disconnect, deadline, fault or unreadable reply can occur after a request was sent. Keep the order and original key in pending reconciliation until you can determine the business outcome. Use the same reconciliation path for Failed, an unrecognized outcome or an Accepted reply whose key or bet ID fails validation.

  1. Query bet status on feedhub-settlements-<instance> using the known bet ID or the saved key. For a lookup by key, send the BetStatusRequest payload {"schemaVersion":1,"betIds":[],"clientBetKeys":["sample-ticket-001"]}. Match the Direct Reply-To response to this lookup’s own requestId and verify the returned identifier.
  2. Open, Settled and Expired identify a recorded acceptance and return its bet ID. Placing calls for another bounded status check. Review NotPlaced with its recorded outcome, keeping any ambiguous provider failure in reconciliation. NotFound means the key or ID was absent at the time of the read. An earlier placement request can still be awaiting processing.
  3. If you retry that same order, use the same client identity, exact original order terms and clientBetKey with a fresh envelope requestId. Store the result against the original order. A fresh key identifies a separate order and can cause a second bet if the first request eventually succeeds.

Commit the settlement before acknowledging it

Section titled “Commit the settlement before acknowledging it”

Use one active reader per client identity on the assigned results queue, with manual acknowledgements and bounded prefetch. Validate the concrete urn:message:FeedHub.Contracts:BetResult type, schema version, client key, bet ID, result and settlement timestamp. Match it to the persisted placement. If the bet association is missing because you lost the placement reply, reconcile it using bet status before applying the result. The settlement consumer acknowledges the received delivery on its own channel.

This pseudocode assumes a durable store with an atomic transaction and a unique settlement record per (client identity, betId). If you also apply results from bet status, use the same transactional write and deduplication rules for both paths.

on settlement delivery(channel, tag, frame):
result = validate BetResult payload and match the persisted bet
key = (configured client identity, result.betId)
begin transaction and serialize writes for key
existing = read settlement record for key
if existing exists:
if it conflicts with result or its committed effect cannot be verified:
roll back the transaction
preserve the delivery for reconciliation and leave it unacknowledged
return
else:
apply the settlement to the bet
insert the deduplication record for key with the applied result
commit transaction
acknowledge tag on channel with multiple=false

Preserve unreadable or unsupported results for investigation. For conflicting results, retain the committed result and reconcile it against bet status before deciding how to acknowledge the conflicting delivery. Settlement wire format · Settlement model

  1. Use a dedicated reader on your assigned sandbox results queue. For the accepted bet, pause that reader once after the settlement and deduplication record commit and before it sends basic.ack.
  2. Close its AMQP channel with that delivery still unacknowledged. Reconnect and start the manual-ack consumer again on the same queue.
  3. Observe the redelivery and verify that the same client identity and betId have exactly one durable settlement effect. Skip the repeated effect and acknowledge this delivery using the tag from the new channel. For example, a HalfWin may arrive on channel A with tag 42 and return on channel B with tag 1. Verify the committed HalfWin before acknowledging tag 1 on channel B.

FeedHub can also publish the same settlement again with a new transport message-id. Apply the same check using the client identity and FeedHub betId.