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.
Remus Rusanu
source share