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
 General SQL Server Forums
 New to SQL Server Administration
 Broker Service: message cannot be received

Author  Topic 

ozSQLServer
Starting Member

32 Posts

Posted - 2011-12-07 : 19:11:40
Hi all,

In my attempt to implement a simple conversation using Borker service in SQL Server 2008, I've successfully executed the following code:


-- set up:
USE master;
GO

ALTER DATABASE AdventureWorks2008R2
SET ENABLE_BROKER;
GO

USE AdventureWorks2008R2;
GO

CREATE MASTER KEY ENCRYPTION BY PASSWORD = 'dyfnds65;sdf%h457!;'
GO

CREATE Message Type AWNewNotice VALIDATION = NONE;
CREATE Message Type AWAck VALIDATION = NONE;

CREATE CONTRACT NewNoticeContract
(AWNewNotice SENT BY ANY, AWAck SENT BY ANY );

CREATE QUEUE AWNewNoticeQueue;
CREATE QUEUE AWAckQueue;

CREATE SERVICE AWNewNoticeService ON QUEUE AWNewNoticeQueue;

CREATE SERVICE AWAckService ON QUEUE AWAckQueue (NewNoticeContract);


-- send message:
DECLARE @dialog_handle uniqueidentifier,
@XMLdata XML;

SET @XMLdata = (SELECT * FROM sys.tables FOR XML AUTO);

BEGIN DIALOG @dialog_handle
FROM SERVICE AWNewNoticeService
TO SERVICE 'AWAckService'
ON CONTRACT NewNoticeContract;

SEND ON CONVERSATION @dialog_handle MESSAGE TYPE AWNewNotice(@XMLdata);



Yet, when I want to receive the message using the following code, I don't find any message to receive.

-- receive:
SELECT * FROM AWNewNoticeQueue;

DECLARE @dialog_handle UNIQUEIDENTIFIER, @XMLdata XML;

RECEIVE TOP (1) @dialog_handle = conversation_handle,
@XMLdata = message_body
FROM AWNewNoticeQueue;


SELECT @XMLData;


Where wrong have I gone??

Thanks in advance.

Cheers,
ozSQL
   

- Advertisement -