Recently, we found a problem with one of our databases where, as a result of the "fire and forget" setting (that is, closing the chains immediately after sending), our sys.conversation_endpoints table was filled with DI / DISCONNECTED_INBOUND messages. This eventually turned into tempDB, causing it to grow dramatically and eat precious disk space. In the end, we solved this problem by commenting out the line
END CONVERSATION @handle WITH CLEANUP
in our sending SP and closing the chains in our receiving SP using the same code,
END CONVERSATION @handle WITH CLEANUP
However, we now have a new problem. Starting with moving servers (and migrating from SQL Server 2005 to SQL Server 2008), we recently discovered that sys.conversation_endpoints is now populated with CO / CONVERSING messages, which indicates that conversations are not closing. The host SP closes them, or at least runs a command for this, so I donβt understand where these messages come from.
I tried to return to the end of the conversation at the point of departure, but this has no effect. Is it wrong to end host conversations with help WITH CLEANUP? Or is there some other problem?
This techtarget post seems to indicate his mistake, and that completing the leftover cleanup task is the only solution ...
UPDATE:
, "" "", SP , . sys.conversation_endpoints STILL, CD/CLOSED.
Send_SP:
DECLARE @h UNIQUEIDENTIFIER
BEGIN DIALOG CONVERSATION @h
FROM SERVICE 'InitiatorQueue' TO SERVICE 'TargetQueue'
ON CONTRACT 'MyContract' WITH ENCRYPTION = OFF;
SEND ON CONVERSATION @h MESSAGE TYPE 'MyMessage' (@msg)
Receive_SP ( SP TargetQueue)
DECLARE @type SYSNAME, @h UNIQUEIDENTIFIER, @msg XML;
DECLARE @target TABLE (
[message_type_name] SYSNAME,
[message_body] VARBINARY(MAX),
[conversation_handle] UNIQUEIDENTIFIER
)
WHILE(1=1)
BEGIN TRANSACTION
WAITFOR(RECEIVE TOP (1000)
[message_type_name],[message_body],[conversation_handle]
FROM TargetQueue INTO @target), TIMEOUT 2000
IF(@@rowcount!=0)
BEGIN
WHILE((SELECT count(*) FROM @target) > 0)
BEGIN
SELECT TOP (1) @type = [message_type_name],
@msg = [message_body],
@h = [conversation_handle] FROM @target;
// Handle Message Here
END CONVERSATION @h;
DELETE TOP (1) FROM @target;
END
END
COMMIT TRANSACTION;
End_SP ( SP InitatorQueue)
DECLARE @type SYSNAME, @h UNIQUEIDENTIFIER, @msg XML;
DECLARE @init TABLE (
[message_type_name] SYSNAME,
[message_body] VARBINARY(MAX),
[conversation_handle] UNIQUEIDENTIFIER
)
WHILE(1=1)
BEGIN TRANSACTION
WAITFOR(RECEIVE TOP (1000)
[message_type_name],[message_body],[conversation_handle]
FROM InitiatorQueue INTO @init), TIMEOUT 2000
IF(@@rowcount!=0)
BEGIN
WHILE((SELECT count(*) FROM @init) > 0)
BEGIN
SELECT TOP (1) @type = [message_type_name],
@msg = [message_body],
@h = [conversation_handle] FROM @init;
END CONVERSATION @h;
DELETE TOP (1) FROM @init;
END
END
COMMIT TRANSACTION;