gotchasqlModerate
Why does WAITFOR (RECEIVE FROM QUEUE) show up in the monitor incorrectly?
Viewed 0 times
showwhythereceivewaitfordoesmonitorincorrectlyfromqueue
Problem
I kick off the following command in my app:
When I run `sp_who2 active', I get Status=SUSPENDED and Command=DELETE
Note: moved from StackOverflow.
WAITFOR (RECEIVE CONVERT(int, message_body) AS Message FROM MyQueue)When I run `sp_who2 active', I get Status=SUSPENDED and Command=DELETE
Note: moved from StackOverflow.
Solution
Because is a DELETE. RECEIVe is just syntactic sugar for something like
If you enable retention then is an UPDATE, and will show as an UPDATE. There are some details, like how conversation group locking is done, how the proper message ExactlyOnceInOrder semantics are ensured and the syntax tree of RECEIVE is not truly possible to be built in T-SQL. As I said, details...
Is no coincidence I recommend in Using Tables as Queues to use the OUTPUT clause of DELETE to 'dequeue' from a table...
DELETE from queue
OUTPUT DELETED.*
WHERE status = ;If you enable retention then is an UPDATE, and will show as an UPDATE. There are some details, like how conversation group locking is done, how the proper message ExactlyOnceInOrder semantics are ensured and the syntax tree of RECEIVE is not truly possible to be built in T-SQL. As I said, details...
Is no coincidence I recommend in Using Tables as Queues to use the OUTPUT clause of DELETE to 'dequeue' from a table...
Code Snippets
DELETE from queue
OUTPUT DELETED.*
WHERE status = <receivable>;Context
StackExchange Database Administrators Q#30624, answer score: 10
Revisions (0)
No revisions yet.