An outbox relay on two hosts, and the partition key

A second host, and a relay that must not run twice against the same rows.

-- each relay claims its partition, derived from the
-- host's ordinal
SELECT * FROM outbox
WHERE published_at IS NULL
  AND CRC32(HEX(aggregate_id)) % 2 = ?
ORDER BY id
LIMIT 200;

-- ordering within an aggregate is preserved, because
-- one aggregate is always handled by one relay.

The modulo on a hash of the aggregate identifier preserves per-aggregate ordering while allowing two relays, and it is the same idea as a broker partition key. Changing the number of relays reshuffles the assignment, so a failover to a single host has to drain first — which is a runbook step and was found in a drill.