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.
Refresh and place the order
Section titled “Refresh and place the order”-
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-idwith the authenticated username. Match replies on their enveloperequestIdand concrete type, then validate the payload schema. -
Publish a pre-bet markets refresh to
feedhub-refresh-<instance>with the chosen market ID. In anOkreply, require aServedevent with a usable snapshot of that exact market and the chosenselectionId. 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 -
Generate a
clientBetKeyand persist it with the original order under your FeedHub client identity before publishing. Place the order usingurn:message:FeedHub.Contracts:BetPlacementRequestonfeedhub-bets-<instance>with routing key"". Put the payload below in the envelope’smessage. Give the request a distinct enveloperequestId. 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"} -
On the matching
BetPlacementReply, requireoutcome: "Accepted", the echoedclientBetKeyand a valid FeedHubbetIdto record acceptance. Persist the association. In this example the accepted bet ID is01967fb0-0a00-7000-8000-000000000311.
Reconcile an uncertain outcome
Section titled “Reconcile an uncertain outcome”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.
- Query bet status on
feedhub-settlements-<instance>using the known bet ID or the saved key. For a lookup by key, send theBetStatusRequestpayload{"schemaVersion":1,"betIds":[],"clientBetKeys":["sample-ticket-001"]}. Match the Direct Reply-To response to this lookup’s ownrequestIdand verify the returned identifier. Open,SettledandExpiredidentify a recorded acceptance and return its bet ID.Placingcalls for another bounded status check. ReviewNotPlacedwith its recorded outcome, keeping any ambiguous provider failure in reconciliation.NotFoundmeans the key or ID was absent at the time of the read. An earlier placement request can still be awaiting processing.- If you retry that same order, use the same client identity, exact original order terms and
clientBetKeywith a fresh enveloperequestId. 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=falsePreserve 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
Exercise redelivery in the sandbox
Section titled “Exercise redelivery in the sandbox”- 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. - Close its AMQP channel with that delivery still unacknowledged. Reconnect and start the manual-ack consumer again on the same queue.
- Observe the redelivery and verify that the same client identity and
betIdhave exactly one durable settlement effect. Skip the repeated effect and acknowledge this delivery using the tag from the new channel. For example, aHalfWinmay arrive on channel A with tag42and return on channel B with tag1. Verify the committedHalfWinbefore acknowledging tag1on 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.