Skip to content

Claim complete groups

The queue as a marketHTTPSDKCLIMCPclaimGroupsoriginIdsizeFacet

A consumer claims whole orders, every unit at once, and only orders whose units have all arrived. No order is ever split across consumers.

The situation

An order of three parts should go to one kitting station together. Parts arrive at different times, and a station that grabs two of three is stuck holding a partial order.

The recipe

workflows/part.ts
const kitted = await conditional<{ kitId: string }>(`kit-${orderId}-${partNo}`, {
role: 'kitting',
originId: orderId,
metadata: { orderId, orderSize: 3 },
});
services/kitting-station.ts
const { data } = await lt.escalations.claimGroups({
query: { role: 'kitting', available: true },
limit: 2,
durationMinutes: 30,
sizeFacet: 'orderSize',
});
// data.groups: whole orders, all units claimed by this station
The same from a terminal
ltc esc claim-groups --role kitting --limit 2 --size-facet orderSize

Units of one order share origin_id. The sizeFacet names the metadata key that holds the order’s unit count. limit is how many orders this consumer can take.

The guarantee

A group is eligible only when its member count equals its declared size. Completeness is re-checked inside the lock, and the claim is one transaction with FOR UPDATE SKIP LOCKED, so concurrent consumers never split a group or claim the same row. See Faceted routing.