Graceful Shutdown¶
TypedBus provides several levels of cleanup for stopping channels and buses.
Close a Channel¶
Stops accepting new publishes and subscribes. Pending deliveries are force-NACKed and routed to the DLQ.
After closing:
publishraisesRuntimeErrorsubscriberaisesRuntimeError- The DLQ retains its entries for inspection
Close All Channels¶
Closes every channel on the bus. Each channel's pending deliveries are force-NACKed.
Clear a Channel¶
Hard reset: cancels all timeout tasks, discards pending deliveries, and clears the DLQ.
Unlike close, clear! does not mark the channel as closed — you can continue using it.
Clear a Bus¶
Clears all channels and resets stats:
Remove a Channel¶
Close and remove a channel from the bus registry:
Removing a nonexistent channel is a no-op.
Shutdown Order¶
For a clean shutdown:
- Stop publishing new messages
- Wait for pending deliveries to resolve (or let timeouts fire)
- Process any DLQ entries
- Call
bus.close_all