Control Framework Stop Queue
Purpose
Section titled “Purpose”Generates a SQL Server script that stops the DIRECT Framework data-logistics state-machine queue — the counterpart to the Start Queue template.
Motivation
Section titled “Motivation”For controlled maintenance — applying a registration update, redeploying changed modules, or pausing data movement during a database upgrade — you want to stop the DIRECT queue jobs cleanly. This template emits a script that calls sp_stop_job for Queue_Batch and Queue_Module, but only if each job is currently active.
Applicability
Section titled “Applicability”- SQL Server family databases with SQL Server Agent enabled.
- DIRECT Framework deployments only.
Design Pattern
Section titled “Design Pattern”N/A — operational control.
Schema Type
Section titled “Schema Type”- All Metadata
Output Type
Section titled “Output Type”- SQL
Implementation guidelines
Section titled “Implementation guidelines”The script targets msdb and checks sysjobactivity to determine whether each queue job is currently executing. Only running jobs are stopped — the script is safe to run unconditionally.
After the stop completes, in-flight modules will continue running to completion, but no new work will be dispatched until the queue is restarted.
Considerations and consequences
Section titled “Considerations and consequences”- Requires
SQLAgentOperatorRoleor higher on the deploying account. - In-flight modules complete normally — this is a graceful stop, not a kill.
- Pair with Start Queue for the maintenance-window pattern.
- If your DIRECT deployment renames the queue jobs, edit the generated SQL or the template to match.
Extensions
Section titled “Extensions”N/A — the template is static SQL.