How idempotent message submission works
mainLiteQueue allows you to associate a single stored message with a unique idempotency_key. This feature makes retrying a put() operation safe in cases of 'ambiguous retries' (e.g., when a network connection fails before the producer receives a response).
Key vs. Message Identity
message_id: A UUIDv7 string that uniquely identifies a specific stored queue message.idempotency_key: An optional, case-sensitive string supplied by the producer to identify a single logical submission.
When you retry a put() with the same idempotency_key and the same data, LiteQueue returns the existing message instead of creating a duplicate. This ensures that even if the first attempt actually succeeded, the second attempt won't result in a second message.
# First attempt
message = queue.put(
'{"account": "A-123", "amount": 10}',
idempotency_key="charge-2026-0001",
)
# If response is lost, retry with the EXACT same data and key
same_message = queue.put(
'{"account": "A-123", "amount": 10}',
idempotency_key="charge-2026-0001",
)
# The message_id will be identical
assert same_message.message_id == message.message_id