I have implemented service broker using rusanu.com articles and advices.

Now I need to implement the following scenario :

The service broker will manage Many messages for differents workers and each worker has to receive it's very own message.

What I tried to implement is first keeping One queue for different workers , each worker having it's own Conversation_group_id to send and receive messages.

So to grab the messages I first have to get the conversation_handle of the first message related to my conversation_group

SELECT TOP 1 @ConversationHandle = Receiveside.conversation_handle
FROM sys.conversation_endpoints Sendside
JOIN sys.conversation_endpoints Receiveside on Receiveside.conversation_id = Sendside.conversation_id 
WHERE Sendside.far_service = @ReceiveService
      AND Sendside.conversation_group_id = @CurrentConversationGroupID
      AND CONVERT( BIT , Receiveside.is_initiator ) = 0  
      AND Receiveside.far_service = @SendService
      AND Sendside.state <> 'CD'
      AND Receiveside.state <> 'CD'

Then I just Receive the message on My queue using the where clause

   RECEIVE message_type_name ,
                conversation_handle ,
                message_body FROM ddr.DataRelayWebServiceReceiveQueue
   INTO @returnTable
  WHERE CONVERSATION_HANDLE = @ConversationHandle 
) , TIMEOUT 1000;

It is functionnal but very poor on the performance side, it takes roughly 25 seconds to dequeue 1500 messages.

I choosed another way which is the creation of as many queues as needed so no collision on the table sys.conversation_endpoints. It takes roughly 16 seconds to dequeue 1500 messages.

I tried to implement Remus rusanu trick which is starting a conversation on the receiving side but without any success.

Any advice on which solution I may choose? I would ideally implement the simple case where two queues could share the same conversation_group_id naturally (without having to search in the table sys.conversation_endpoints), If any of you have already managed to do that I would gladly accept any advice.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.