MailboxProcessor retry policy with idempotency key for external writes
0 reputation · 30 Jan 2020, 14:46 UTC
MailboxProcessor retry policy with idempotency key for external writes
Goal: configure an FSharp.Core MailboxProcessor<T> agent to retry a failed message after a transient fault while ensuring the corresponding external write is not duplicated. The agent serializes messages on a single in-process thread, so retried attempts do not overlap, but the mailbox itself is in-memory and is discarded on restart.
Constraint: MailboxProcessor exposes no built-in retry policy, persistence, replay queue, or idempotency-key parameter on its constructors or Post, PostAndAsync, and Scan methods. The application must supply deduplication tokens and validate them against an external store, but it is unclear where token generation and store checks should sit relative to the agent's receive loop without blocking unrelated messages.
Version assumption: current FSharp.Core MailboxProcessor API has no durable retry configuration.
Specific questions:
- Should the idempotency key be generated inside the agent before the write attempt, or by the caller before posting the message?
- How can a retry be scheduled without stalling the mailbox while waiting on an external deduplication store?
- What happens to pending retry state and deduplication tokens when the agent restarts?