Hi,
I am using service broker in between two database servers. following is the way i am sending and receiving messages
Send
BEGIN TRAN
BEGIN DIALOG CONVERSATION @.handle
FROM SERVICE @.SendService
TO SERVICE @.ReceiveService
ON CONTRACT @.Contract
WITH LIFETIME = @.lifetime;
SEND ON CONVERSATION @.handle
MESSAGE TYPE @.xmlMessageType(@.xmlMessage);
COMMIT
Receive
BEGIN TRAN;
RECEIVE TOP(1) @.xmlMessage = message_body,
@.handle = conversation_handle,
@.message_type = message_type_name
FROM TransactionQueue;
-
-- Check to make sure a message was returned to process. In theory this should never happen.
-
IF @.@.rowcount = 1
BEGIN
IF @.message_type = 'http://schemas.microsoft.com/SQL/ServiceBroker/EndDialog'
BEGIN
END CONVERSATION @.handle;
COMMIT
RETURN 0
END
IF @.message_type = N'http://schemas.microsoft.com/SQL/ServiceBroker/Error'
BEGIN
RAISERROR(N'Received error %s from service [Target]', 10, 1)
END CONVERSATION @.handle;
COMMIT
RETURN 0
END
SET @.sql = 'EXEC '+@.message_processor_name+' @.xml'
BEGIN TRAN
EXEC sp_executesql @.sql, N'@.xml XML', @.xml=@.xmlMessage
COMMIT TRAN
END CONVERSATION @.handle;
END
COMMIT
I see Messages are delivered to the target every thing working fine other than following errors which i am seeing in profiler.
1) "This message could not be delivered because the conversation endpoint has already been closed." I see this error on initiator end. Is it like ending conversation on initiator end when i get "EndDialog" send an acknowledgement, which cannot be recieved by target as it has already ended conversation.
2) "An error occurred while receiving data: '64(The specified network name is no longer available.)'." I don't have much idea about the reason for this error. But in profiler i see value for GUID is different for this error and the real message.
Let me know if you need any other information
Please let me know if I have missed anything in above post|||
Just wondering if you resolved this issue as I am having the same issues with very similar code.
If you have resolved this, could you share what you did please so that I can (hopefully) resolve my problems too?
Thanks in advance.
No comments:
Post a Comment