GET CONVERSATION GROUP (Transact-SQL)
Returns the conversation group identifier for the next message to be received, and locks the conversation group for the conversation that contains the message. The conversation group identifier can be used to retrieve conversation state information before retrieving the message itself.
Important
|
|---|
|
If the GET CONVERSATION GROUP statement is not the first statement in a batch or stored procedure, the preceding statement must be terminated with a semicolon (;), the Transact-SQL statement terminator. |
If the queue specified in the GET CONVERSATION GROUP statement is unavailable, the statement fails with a Transact-SQL error.
This statement returns the next conversation group where all of the following is true:
-
The conversation group can be successfully locked.
-
The conversation group has messages available in the queue.
-
The conversation group has the highest priority level of all the conversation groups that meet the previously-listed criteria. The priority level of a conversation group is the highest priority level assigned to any conversation that is a member of the group and has messages in the queue.
Successive calls to GET CONVERSATION GROUP within the same transaction may lock more than one conversation group. If no conversation group is available, the statement returns NULL as the conversation group identifier.
When the WAITFOR clause is specified, the statement waits for the timeout specified, or until a conversation group is available. If the queue is dropped while the statement is waiting, the statement immediately returns an error.
GET CONVERSATION GROUP is not valid in a user-defined function.
A. Getting a conversation group, waiting indefinitely
The following example sets @conversation_group_id to the conversation group identifier for the next available message on ExpenseQueue. The command waits until a message becomes available.
DECLARE @conversation_group_id UNIQUEIDENTIFIER ;
WAITFOR (
GET CONVERSATION GROUP @conversation_group_id
FROM ExpenseQueue
) ;
B. Getting a conversation group, waiting one minute
The following example sets @conversation_group_id to the conversation group identifier for the next available message on ExpenseQueue. If no message becomes available within one minute, GET CONVERSATION GROUP returns without changing the value of @conversation_group_id.
DECLARE @conversation_group_id UNIQUEIDENTIFIER
WAITFOR (
GET CONVERSATION GROUP @conversation_group_id
FROM ExpenseQueue ),
TIMEOUT 60000 ;
C. Getting a conversation group, returning immediately
The following example sets @conversation_group_id to the conversation group identifier for the next available message on ExpenseQueue. If no message is available, GET CONVERSATION GROUP returns immediately without changing @conversation_group_id.
DECLARE @conversation_group_id UNIQUEIDENTIFIER ; GET CONVERSATION GROUP @conversation_group_id FROM AdventureWorks.dbo.ExpenseQueue ;