| Previous | Next |
| MQ_ERROR_MISSING_CONNECTOR_TYPE | MQ_ERROR_TRANSACTION_ENLIST |
MQ_ERROR_STALE_HANDLE
What this result actually narrows down
MQ_ERROR_STALE_HANDLE means queue handle belongs to an earlier MSMQ service generation. A service restart invalidates open handles even if the queue still exists.
For asynchronous or transactional reads, cleanup must be coordinated with callback and transaction owners. When diagnosing this result, closing a handle from another thread can be the cause rather than the cure.
Queue handles and lookup identifiers are not permanent names. Service restart, queue deletion/recreation, purge, expiration, transaction rollback, and another receiver can invalidate assumptions made earlier.
MSMQ objects involved
| Subsystem | queue and handle lifetime across deletion, service restart, asynchronous reads, and competing consumers |
|---|---|
| Relevant condition | an object that was valid when opened may no longer identify the same queue-manager generation or message |
| Code-specific focus | queue handle belongs to an earlier MSMQ service generation |
The same pathname does not prove object identity across restart or recreation. Handles and message lookup IDs belong to a particular lifetime. The code-specific boundary is queue handle belongs to an earlier MSMQ service generation.
Triage data
- Handle creation time and msmq service restart time.
- Queue deletion/recreation events and current format name.
- Lookup id, cursor action, transaction, and competing consumer activity.
Correct response
Close and reopen the queue; repeating calls on the stale handle cannot recover.
What this code is not
Reusing the same pathname after restart or recreation does not revive the old handle, lookup identifier, message lock, or transaction context. Code-specific condition: queue handle belongs to an earlier MSMQ service generation.
Example failure path
An asynchronous receive loop encounters it. It closes invalid objects, resolves the current queue generation, and reconciles whether another consumer completed the work.
Technical references
Looking for a different code? Search another status or error code.