Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Service Broker (2005)
 Conversation Groups

Author  Topic 

jhomer
Starting Member

1 Post

Posted - 2007-02-23 : 12:28:55
Can someone please help with this service broker question. I'm trying to send messages on a User defined conversation group. But for some reason the group is not being persisted. Can someone tell my how to correct the problem?

Here's the code...

create database db1
Go

alter database db1 set trustworthy on
Go

create database db2
Go


use db1
go

drop service [testService];
drop queue [testQueue];
go

use db2

drop service [targetService];
drop queue [targetQueue];
go

use db1
Go

create queue [testQueue];
create service [testService] on queue [testQueue]; go

use db2
Go

create queue [targetQueue];
create service [targetService] on queue [targetQueue] ([DEFAULT]); go

Use db1
Go

declare @cg uniqueidentifier;
declare @h uniqueidentifier;
declare @SBGuid uniqueidentifier;

select @cg = '849051CA-52BC-DB11-8673-00061BDFF17D';

Select @SBGuid = service_broker_guid from sys.databases where name = 'db2'

begin dialog conversation @h
from service [testService]
to service N'targetService', @SBGuid
with related_conversation_group = @cg,
encryption = off;
send on conversation @h;

begin dialog conversation @h
from service [testService]
to service N'targetService', @SBGuid
with related_conversation_group = @cg,
encryption = off;
send on conversation @h;

begin dialog conversation @h
from service [testService]
to service N'targetService', @SBGuid
with related_conversation_group = @cg,
encryption = off;
send on conversation @h;

use db2
Go

declare @cg uniqueidentifier;
Set @cg = '849051CA-52BC-DB11-8673-00061BDFF17D';

receive top (1) * from [targetQueue]
Where conversation_group_id = @cg

The final recieve should get the first of the three messages that was sent. Running again should get the second, and again for the third.

Regards
   

- Advertisement -