bonza


I try to do conversation sending without any errors.And with clean sys.conversation_endpoints.

There is my activation procedure code:

Code Snippet

SET NOCOUNT ON

DECLARE @ConversationHandle UNIQUEIDENTIFIER

DECLARE @ConversationGroupID UNIQUEIDENTIFIER

DECLARE @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

BREAK

END

END

END

SET NOCOUNT OFF

The 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




Re: How do it right?

TimDBA


Your queue is closed, and it might be closed because you have a poison message. Add TRY...CATCH error handling to your code and record any errors received to an error log table. First, however, you will need to enable your queue:

ALTER QUEUE WITH Status = ON.

If you are using activation, which I assume that you are:

ALTER QUEUE WITH Status = ON, ACTIVATION(Status = ON)

information on poison messages: http://technet.microsoft.com/en-us/library/ms171592(SQL.90).aspx







Re: How do it right?

GMan2

You can check your status by running....

Select * from sys.service_Queues

Look at the Is_Activation_Enabled, Is_receive_enabled, etc.