Interface WeixinStateStore
public interface WeixinStateStore
Account-scoped state for at-least-once message processing. Implementations must atomically
validate the unexpired lease on every mutation. External Agent and provider side effects are
not part of this transaction and can be repeated after a crash.
-
Method Summary
Modifier and TypeMethodDescriptionbooleanabandonMessage(String accountId, WeixinLease lease, WeixinInboxClaim claim) Drops a claimed message the consumer will not retry again — the dispatch kept failing, or the provider kept refusing the reply.booleanacceptBatch(String accountId, WeixinLease lease, String nextCursor, List<WeixinInboxMessage> messages) Saves the whole batch and its cursor in one transaction, deduplicating message IDs.acquireLease(String accountId, String holderId, long leaseMs) A released or expired lease must never reuse its generation, even for the same holder.claimMessages(String accountId, WeixinLease lease, int limit, long claimMs) Claims in reception order.booleancompleteMessage(String accountId, WeixinLease lease, WeixinInboxClaim claim) Only the exact, unexpired claim may finish.booleanfailMessage(String accountId, WeixinLease lease, WeixinInboxClaim claim) static WeixinStateStoreinMemory()booleanisLeaseCurrent(String accountId, WeixinLease lease) loadContextToken(String accountId, String peerId) loadCursor(String accountId) voidreleaseLease(String accountId, WeixinLease lease) default voidremoveAccount(String accountId) Forgets everything held foraccountId: cursor, peer context tokens and inbox.booleanrenewLease(String accountId, WeixinLease lease, long leaseMs) booleansaveContextToken(String accountId, WeixinLease lease, String peerId, String token)
-
Method Details
-
loadCursor
-
loadContextToken
-
saveContextToken
-
acquireLease
A released or expired lease must never reuse its generation, even for the same holder. -
renewLease
-
isLeaseCurrent
-
releaseLease
-
acceptBatch
boolean acceptBatch(String accountId, WeixinLease lease, String nextCursor, List<WeixinInboxMessage> messages) Saves the whole batch and its cursor in one transaction, deduplicating message IDs. -
claimMessages
Claims in reception order. A new lease may immediately recover the previous owner's work. -
completeMessage
Only the exact, unexpired claim may finish. Completed payloads must be removed. -
failMessage
-
abandonMessage
Drops a claimed message the consumer will not retry again — the dispatch kept failing, or the provider kept refusing the reply. The message is tombstoned so a re-delivered batch cannot resurrect it, but it is not reported as completed. -
removeAccount
Forgets everything held foraccountId: cursor, peer context tokens and inbox.Hosts call this when an account is retired so a long-lived process does not accumulate state for accounts it no longer serves. Implementations that hold no per-account state can leave the default no-op.
-
inMemory
-