HI
I have an example ( see below ).
I expect to have all messages sent using this code to have the same group id but they are all different. what I am doing wrong?
Leonid.
DECLARE @.conversationHandle uniqueidentifier
DECLARE @.usergroup uniqueidentifier
select @.usergroup = uid from bvuser where userid = 1
select @.usergroup
Begin Transaction
BEGIN DIALOG @.conversationHandle
FROM SERVICE [BvMainResponseService]
TO SERVICE 'BvMainService'
ON CONTRACT [BvMainContract]
WITH RELATED_CONVERSATION_GROUP = @.usergroup;
-- Send a message on the dialog
SEND ON CONVERSATION @.conversationHandle
MESSAGE TYPE [BvTaskMsg]
(N'Test')
commit
As far as i understand it you expand a conversation group by adding additional dialogs related to the first one:
For example:
DECLARE @.conversationHandle uniqueidentifier
Begin Transaction
BEGIN DIALOG @.conversationHandle
FROM SERVICE [BvMainResponseService]
TO SERVICE 'BvMainService'
ON CONTRACT [BvMainContract]
WITH RELATED_CONVERSATION_GROUP = @.conversationHandle;
-- Send a message on the dialog
SEND ON CONVERSATION @.conversationHandle
MESSAGE TYPE [BvTaskMsg]
(N'Test')
commit
You keep using the conversation handle from the begin dialog to keep the same conversation, i could be mistaken as i have not really tried it , but i think that is the theory anyway.
Thanx
|||
this is from BOL
If related_conversation_group_id does not reference an existing conversation group, the service broker creates a new conversation group with the specified related_conversation_group_id and relates the new dialog to that conversation group.
so as I understand this - new conversation group id is created when BEGIN DIALOG is used for the first time with specified ID, and then ... here is BOL again
Specifies the existing conversation group that the new dialog is added to. When this clause is present, the new dialog will be added to the conversation group specified by related_conversation_group_id.
But obviously I am doing something wrong here becuase it doesn't work as I expect it.
Leonid.
|||In the test you've shown the conversation should have the same conversation group id. How are you looking up the conversations?
Here is a test script that shows that the related_conversation_group creates conversation in the same group, and the first BEGIN CONVERSATION creates the group itself, just as you expect:
use [tempdb];
go
create queue [testQueue];
create service [testService] on queue [testQueue];
go
create queue [targetQueue];
create service [targetService] on queue [targetQueue] ([DEFAULT]);
go
declare @.cg uniqueidentifier;
declare @.h uniqueidentifier;
select @.cg = newid();
begin dialog conversation @.h
from service [testService]
to service N'targetService', N'current database'
with related_conversation_group = @.cg,
encryption = off;
send on conversation @.h;
begin dialog conversation @.h
from service [testService]
to service N'targetService', N'current database'
with related_conversation_group = @.cg,
encryption = off;
send on conversation @.h;
begin dialog conversation @.h
from service [testService]
to service N'targetService', N'current database'
with related_conversation_group = @.cg,
encryption = off;
send on conversation @.h;
select * from sys.conversation_endpoints where conversation_group_id = @.cg;
HTH,
~ Remus
No comments:
Post a Comment