Tuesday, March 20, 2012

conversation_handle in Queue doesn't match "SEND ON CONVERSATION..." value.

When examining the "conversation_handle" column value in the Queue (from: "select * from ProcessQueue"), I find the value of the conversation_handle appears to be different from the "conversation handle" ("SEND ON CONVERSATION @.conversationHandle...") on which the message was sent.

I'm trying to gather all messages for a given Dialog conversation, but am not able to do this because the conversation_handle doesn't appear consistent between messages in the Dialog.

note: the conversation_handle of "BEGIN CONVERSATION TIMER (@.conversationHandle)..." message does appear to be correct in the Queue.

Thoughts on why the conversation_handle listed in the Queue might be different than that of the
"SEND ON CONVERSATION @.conversationHandle..." command that sends the message?

-
-
-


ALTER PROCEDURE [dbo].[SendMessageStoredProcedure]
AS

-- Declare Conversation Handle
DECLARE @.conversationHandle uniqueidentifier;

-- Declare Message
DECLARE @.message nvarchar(max);

-- Begin Transaction
BEGIN TRANSACTION;

-- Begin Dialog from Service1 to Service2 on Contract
BEGIN DIALOG @.conversationHandle
FROM SERVICE ExecuteProcess
TO SERVICE 'ExecuteProcess'
ON CONTRACT Process;


FROM DEBUGGER: @.conversationHandle has value of AC8DF4E0-9F38-DB11-96A2-000CF1D46448

-- Set Message value
DECLARE @.requestDocument xml
SET @.requestDocument = N'<ProcessRequestMessage/>';

-- Start Converstation time
BEGIN CONVERSATION TIMER (@.conversationHandle) TIMEOUT = @.queueSeconds;

-- Send Message
SEND ON CONVERSATION @.conversationHandle MESSAGE TYPE ProcessRequest (@.requestDocument);

-- Commit Transaction
COMMIT TRANSACTION;

-
-
-

RESULTS OF: select * from ProcessQueue;

status priorty q_order conversation_group_id conversation_handle msg_s_# service_name ser_id srv_cont_name ...
1 0 1 AD8DF4E0-9F38-DB11-96A2-000CF1D46448 AC8DF4E0-9F38-DB11-96A2-000CF1D46448 -2 ExecuteProcess 65536 Process 65536 http://schemas.microsoft.com/SQL/ServiceBroker/DialogTimer 5 E NULL
1 0 0 AE8DF4E0-9F38-DB11-96A2-000CF1D46448 AF8DF4E0-9F38-DB11-96A2-000CF1D46448 0 ExecuteProcess 65536 Process 65536 ProcessRequest 65536 X 0xFFFE3C004400610074006100620...

Conversation handles uniquely identify a conversation endpoint. Since a dialog has two endpoints (the initiator and the target), it will have two conversation handles. The handle returned by the BEGIN DIALOG statement is the conversation handle at the initiator whereas the one in the target queue is the handle for the target endpoint of the dialog.

Conversation IDs, on the other hand, uniquely identify a conversation. Hence for a dialog, you will notice that the conversation ID is the same at the initiator and the target.

You can see converstaion_handle, conversation_id and other properties of your conversation endpoints by looking at the sys.conversation_endpoints view.

|||Thanks! ...exactly the clarification I needed.

No comments:

Post a Comment