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.
Author |
Topic |
sg2255551
Constraint Violating Yak Guru
274 Posts |
Posted - 2007-02-21 : 11:15:22
|
hii have a sample code but when i query on the queue is empty and i do not know why?IF NOT EXISTS(SELECT * FROM sys.databasesWHERE name = 'AdventureWorks'AND is_broker_enabled = 1)BEGINALTER DATABASE AdventureWorks SET ENABLE_BROKER ;END-- Create the XML SBSampleMessage message typeCREATE MESSAGE TYPE SBSampleMessageVALIDATION = WELL_FORMED_XML ;GO-- Create the SBSampleContract contractCREATE CONTRACT SBSampleContract( SBSampleMessage SENT BY INITIATOR);GO-- Create the queueCREATE QUEUE [dbo].[ReceiverQueue];GO-- Create the queue for the Sender serviceCREATE QUEUE [dbo].[SenderQueue];GO-- Create the serviceCREATE SERVICE SenderServiceON QUEUE [dbo].[SenderQueue];GO-- Create the target serviceCREATE SERVICE ReceiverServiceON QUEUE [dbo].[ReceiverQueue](SBSampleContract);GO----SELECT * FROM dbo.ReceiverQueue--Select * from SenderQueue--Select * from dbo.ServiceBrokerQueueUSE AdventureWorks ;GO-- Begin a transactionBEGIN TRANSACTION ;GO-- Declare a variable for the messageDECLARE @SBmessage XML ;SET @SBmessage = N'<message>Service Broker is Cool</message>' ;-- Declare a variable for the conversation IDDECLARE @conversationID UNIQUEIDENTIFIER ;-- Begin a dialog between the servicesBEGIN DIALOG CONVERSATION @conversationIDFROM SERVICE SenderServiceTO SERVICE 'ReceiverService'ON CONTRACT SBSampleContract ;-- Put the message on the queueSEND ON CONVERSATION @conversationIDMESSAGE TYPE SBSampleMessage(@SBmessage) ;-- End the conversationEND CONVERSATION @conversationID ;GO-- Commit the transaction to send the messageCOMMIT TRANSACTION ;GOUSE AdventureWorks ;GOSELECT * FROM [dbo].[ReceiverQueue]USE AdventureWorks ;GOSELECT CAST(message_body as nvarchar(MAX)) from ReceiverQueue |
|
|
|
|