I try to do conversation sending without any errors.And with clean sys.conversation_endpoints.
There is my activation procedure code:
SET
NOCOUNT ONDECLARE
@ConversationHandle UNIQUEIDENTIFIERDECLARE
@ConversationGroupID UNIQUEIDENTIFIERDECLARE
@MessageType NVARCHAR(126)DECLARE
@Message VARBINARY(MAX)DECLARE
@MessageXML XML;WHILE
(1 = 1)BEGIN
SET @ConversationGroupID = NULL
WAITFOR(GET CONVERSATION GROUP @ConversationGroupID FROM [AGCapital/ServiceBroker/Queues/BrokerBug]), TIMEOUT 1000;
IF @ConversationGroupID IS NULL
BEGIN
BREAK
END
WHILE (1 = 1)
BEGIN
SET @MessageType = NULL
SET @Message = NULL
SET @ConversationHandle = NULL;
RECEIVE TOP(1) @ConversationHandle = conversation_handle, @MessageType = message_type_name, @Message = message_body
FROM [AGCapital/ServiceBroker/Queues/BrokerBug]
WHERE conversation_group_id = @ConversationGroupID
IF @@ROWCOUNT = 0
BEGIN
BREAK
END
IF @MessageType = 'http://schemas.microsoft.com/SQL/ServiceBroker/EndDialog'
OR @MessageType = 'AGCapital/ServiceBroker/Messages/Received'
BEGIN
END CONVERSATION @ConversationHandle;
BREAK
END
ELSE IF @MessageType = 'AGCapital/ServiceBroker/Messages/BrokerBug'
BEGIN
SET @MessageXML = CONVERT(XML,@Message);
SEND ON CONVERSATION @ConversationHandle MESSAGE TYPE [AGCapital/ServiceBroker/Messages/Received];
--do something
BREAKEND
END
END
SET
NOCOUNT OFFThe code is identical on both services, Target and Iniciator. You can see, that it's work with it's own garanteed delivering system - conversation endeds only when it's have confirmation of receiving mesage type AGCapital/ServiceBroker/Messages/BrokerBug'
Looks like everything is rigth, but.. Profiler still show couple errors: on the Target server it is
This message could not be delivered because the 'receive end conversation' action cannot be performed in the 'CLOSED' state.
and on the iniciator
An error occurred while receiving data: '64(error not found)'.
Have you any ideas why it's happened