MSMQ transaction lifecycle¶
Manages the lifecycle of an MSMQ MessageQueueTransaction, allowing a caller to batch multiple queued document sends under a single commit or abort.
| Field | Value |
|---|---|
| Operation ID | OP-PRINT-MSMQ-TXN |
| Trigger | Caller invokes StartMQTransaction() before one or more distributeDocument (asynchronous) calls, then EndMQTransaction(inAction) |
| Inputs | inAction (Boolean: commit vs. abort) for EndMQTransaction |
| Outputs | Committed or aborted MessageQueueTransaction |
| Primary components | clsPrint.StartMQTransaction, clsPrint.EndMQTransaction |
| Entry point | SAIF.Services.Printing\clsPrint.vb |
Steps¶
StartMQTransaction: if no transaction is already started, creates a newMessageQueueTransaction, callsBegin(), and sets an internal "started" flag — allows a caller to batch multiple queued sends under one transaction before calling Distribute a document.EndMQTransaction(inAction): if a transaction was started, commits (inAction = True) or aborts (inAction = False) it.- Always resets the "started" flag and disposes the transaction object in a
Finallyblock, regardless of outcome.
Process flow¶
flowchart TD
Start([StartMQTransaction called]) --> Check{Transaction already started?}
Check -->|No| Create[Create MessageQueueTransaction and Begin]
Check -->|Yes| Reuse[Reuse existing transaction]
Create --> Ready([Ready for queued sends])
Reuse --> Ready
Ready --> End([EndMQTransaction called])
End --> Action{inAction?}
Action -->|True| Commit[Commit transaction]
Action -->|False| Abort[Abort transaction]
Commit --> Dispose[Reset flag and dispose transaction]
Abort --> Dispose
Failure and edge-case behavior¶
- The transaction object is always disposed in a
Finallyblock, so a transaction is never left open regardless of commit/abort outcome or an intervening exception.
Related documentation¶
Sources¶
SAIF.Services.Printing\clsPrint.vb