Sql Server Service Broker Conversation Groups

Can someone explain the conversation groups in the service broker?

I am currently using a service broker to send messages from one SQL server to another. On the sending server, I try to match messages so that they are processed sequentially on the receiving side. Based on the documentation, conversation groups seem to be perfect for this, but on the receiving server, messages are assigned to another conversation group from the one I specified when sending the message.

I searched on the internet and saw that this behavior seems to be intended ( http://social.msdn.microsoft.com/forums/en-US/sqlservicebroker/thread/baf48074-6804-43ab-844a-cb28a6dce02b/ ) but then I am confused about the usefulness of the syntax from ( http://msdn.microsoft.com/en-us/library/ms178624.aspx )

WAITFOR( GET CONVERSATION GROUP @conversation_group_id FROM [dbo].[ReceiveQueue] ) 

If the conversation group does not encounter a message from the sender, and the messages sent with the same conversation group identifier do not have the same conversation group identifier on the receiving side, what is the point of the above code?

+6
sql-server service-broker
source share
1 answer

Conversation groups are local primitives used to block. Messages in a conversation group do not have order guarantees, and conversation groups do not pass through postings.

Message ordering is guaranteed by Service Broker during the conversation. Therefore, to preserve the order of processed messages in processing, send them to the same conversation.

Talk groups are needed to group a set of conversations that are related to each other. Both the verbs GET CONVERSATION GROUP and RECEIVE ensure that they block the entire conversion group, thereby preventing any other stream from processing related messages. For example, consider a mobile site. He receives a message requesting a holiday package reservation. As a result, he initiates a conversation with the hotel reservation service and sends a request for booking a room, he initiates a conversation with the airline reservation service and asks for a trip reservation, he initiates a conversation with a car rental agency and requests a car reservation. These three new conversations that he created are in the same group as the initial conversation that the request was received (the application used the WITH RELATED_CONVERSATION BEGIN DIALOG WITH RELATED_CONVERSATION on all 3 of them). Then it commits and proceeds to processing messages in the queue. Later, the responses from these 3 correlated queries begin to arrive at quite a few random times. Say hotel resposnse comes first. The message is picked up by the application and it continues to update the status of the request with a response from the hotel. At the same time, an airline response appears. If another thread is allowed to pick it up, it will try to update the status of the same request, which will lead to blocking or even a deadlock against the thread that processes the hotel’s reaction. When the hotel’s reaction is processed, the thread will record and thus unlock the entire conversation group , allowing any stream (including itself) to pick up the airline’s response and process it.

+18
source share

All Articles